I need help for a regular expression.
My search can't find something useful so far. My string looks like:
E32;E223;E0;A1023
I would like to get the values E32 and E223 and E0 and A1023.
What is the best regex syntax for it?
Any help would be appreciated.
Thanks,
You may use this: [^;]+ or \w+.
This will give you every semicolon separated token, and will exclude empty tokens.
Edit: also you can and should use "E32;E223;E0;A1023".split(";") like falsetru mentioned in the comments (providing your language supports this -> which it probably does).
Related
I'd like to replace wrongly formatted text in multiple documents. Instead of the proper way like this
»Citation«
words have been cited like this
«Citation»
(or some other combination like »Citation»)
Now, I know there is the Regular Expression, which I'd use like this for the opening mark:
«[A-Z]
But how does the replace string look like? It doesn't work with "»", neither with "»[A-Z]", neither with "»*"....
I guess there is a very simple solution, but I haven't found any answer in the different forums. Thanks for any advice!
Search for:
«([A-Z]+)»
Replace with:
»$1«
For documentation, look under ( ) in the Character column at: https://help.libreoffice.org/Common/List_of_Regular_Expressions.
I am working with regular expressions, I need to create an expression for validating strings against the following scenario:
Solution.<word1|word2|word3>.<word4|word5>.anyword.(any word containing proj in it)
I tried
Solution.\b(word1|word2|word3)\b.\b(word4|word5)\b.(.*).\b(.*proj)\b
But this allows strings like Solution.word1.word4.blabla.blabla.csproj, meaning it allows anything before the proj because of the .*.
Can someone help me with this??
Looks like you need this regex:
Solution\.(word1|word2|word3)\.(word4|word5)\.([^.]+)\..*?\bproj\b
RegEx Demo
You might want to try (need to escape the . and allow capturing group to have chars except .):
Solution\.\b(word1|word2|word3)\b\.\b(word4|word5)\b\.([^\.]*)\.\b([^\.]*proj)\b
It's hard to consider the actual strings you want to allow without more clarification.
You can try the following regular expression.
Solution\.word[123]\.word[45]\.\w+\.\w*proj\b
I would like to remove hundreds on onmouseover events from my code. the evt all pass different variables and I want to be able to use dreamwaever to find and replace all the strings with nothing.
Here is an example
onmouseover="parent.mv_mapTipOver(evt,'Wilson');"
onmouseover="parent.mv_mapTipOver(evt,'Harris');"
onmouseover="parent.mv_mapTipOver(evt,'Walker');"
I want to run a search that will identify all of these and replace/remove them.
I have tried seemingly infinite permutations of things like:
onmouseover="parent.mv_mapTipOver(evt,'[^']');"
or
onmouseover="parent.mv_mapTipOver(evt,'[^']);"
or
onmouseover="parent.mv_mapTipOver(evt,[^']);"
or
onmouseover="parent.mv_mapTipOver(evt,'[^']+');"
And many more. I cannot find the regular expression that will work.
Any/all help would be appreciated.
Thanks a ton!
"." and "(" have special meaning in regular expressions, so you need to escape them:
onmouseover="parent\.mv_mapTipOver\(evt,'[^']+'\);"
I'm not sure if this is correct dreamweaver regex syntax, but this stuff is standard enough.
Try this one:
onmouseover="parent\.mv_mapTipOver\(evt,'.+?'\);"
And see it in action here.
When using reg expressions you have to be very careful about how you handle white space. For example the following piece of code will not get caught by most of the reg expressions mentioned so far because of the space after the comma and equals sign, despite the fact that it is most likely valid syntax in the language you are using.
onmouseover= "parent.mv_mapTipOver(evt, 'Walker');"
In order to create regexp that ignore white space you must insert /s* everywhere in the regexp that white space might occur.
The following regexp should work even if there is additional white space in your code.
onmouseover\s*=\s*"parent\.mv_mapTipOver\(\s*evt\s*,\s*'[A-Za-z]+'\s*\);"
What would regular expression look like for any string which ends with .txt?
Tried few myself but it doesn't look like I'm getting anywhere.
I'd like to construct a regex object to feed a function.
Something like : .*\.txt$
If you want more precisions, I guess you should precise a language and some other stuffs...
All you have to do is match the end of the string using
/\.txt$/
Matching more than that e.g., .*\.txt$ is not necessary
Assuming Perl-style regular expressions, /[^\.]*\.txt$/ should work.
I'm having trouble coming up with a regular expression for a string in the given form:
123123<key:value><key:value>,21313<key:value><key:value>
where the key:value pairs are optional, but we must not have two colons in the same key:value pairs.
I've gotten this far:
^((\d+)(<(.+?):(.+?)>)*)(,\d+)(<(.+?):(.+?)>)*$
some valid texts:
123131
123131, 123131, 1213313
12313<key:value>
232133<key:value><key:value>,232133<key:value><key:value>
Try this:
^((\d+)(<(.+?):(.+?)>){0,2})(,\s*((\d+)(<(.+?):(.+?)>){0,2}))*$
Depending on which group you don't want to capture, you can change ( ) to (?: ).
Rubular link
Try using this ^(\d+(<.+:.+>){1,2})(,\d+(<.+:.+>){1,2})*$ Hope it helped
Thanks a lot for your responses, but none of them seem to do excactly what I'm looking for. I think maybe the easies thing is to follow OrangeDogs suggestion considering maintainability as well...