RegEx: Modify text between sh. and ( to lowercase
-
Hi,
I need help again in term of using regular expression for filtering.I have a lot of text to modify.
The part of the text I have to modify to lower case after sh. and before (.Here are two examples:
sh.Wetter.Darksky.currently.windSpeed.beaufort_string(“Windstille”)
sh.Tankstellen.Metro_Eibach.diesel(element[‘diesel’])to be be converted to
sh.wetter.darksky.currently.windSpeed.beaufort_string(“Windstille”)
sh.tankstellen.metro_eibach.diesel(element[‘diesel’])Thank you!
-
you can easily do this by using a regex search/replace in notepad++
find what:
(sh.)(.*?)(\()
replace with:$1\L$2$3
search mode: regular expressiongives you:
sh.wetter.darksky.currently.windspeed.beaufort_string("Windstille") sh.tankstellen.metro_eibach.diesel(element['diesel'])
as result
-
THX
-
you’re welcome.
here’s a little explanation to get you started using regex so that you can easily adapt them for your needs:
search what:
(s.h)
:
the first is the beginning text that you are searching for
the brackets ( and ) define a string buffer, which will be available at the replace as variable $1.
every time you enclose another section in brackets, you will create a new string buffer variable $2 and so on.(.*?)
:
this states that the text in between your beginning and the end can be anything with any length.
it’s content will be reflected as $2(\()
:
this marks your end search character ( where you want to stop converting to lower case.
note: this looks weird, but it’s basically a ( bracket in between two brackets.
to make sure it is interpreted as text and not as a bracket that opens another buffer, it has to be “escaped” marked with a preceeding \.
it’s easier to read if some spaces are inserted:( \( )
replace with:
$1\L$2$3
this needs almost no further information.
the string buffer variables $1 $2 and $2 are put together without spaces, and \L before $2 converts the second string variable to lower case -
-
i’d call it a typo …
you’re not in a good mood today, am i right ? -
Nono…mood is fine. You seem like a humorous guy, with all the emojis, thought you’d like the “facepalm” thing. Sorry. Certainly didn’t intend to offend.
-
@Alan-Kilborn
ahhh …
i only know text based face palm as:(-‸ლ)
😂
glad you’re in a good mood, i was worried a bit, and i tend to ask freely.
-
OOKKKAAAYY - everybody seems to know what facepalms means except … MEEEE. :-)
What does it mean?? -
I think a possible explanation for facepalm is “I can’t believe I did that”. In the usage above, making a mistake in the regex you are trying to explain the meaning of yields that reaction.
-
if you hear or see something so stupid, that you have to hit your face with your open hand, it’s called a face palm
(-‸ლ)
-
LOL :-D
-
and i still call it a typo !!! ;-)
btw: we’ve just hijacked another thread … but it’s fun from time to time 👍
-
🤦 U+1F926 (https://emojipedia.org/face-palm/)
-
i guess from now on
(s.h)
is gonna pursue me as hidden insider to a facepalm (-‸ლ)
😂😂😂 -
@PeterJones said:
🤦 U+1F926 (https://emojipedia.org/face-palm/)
even easily understandable for me :-D