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.
Related
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).
I am building a search functionality and I am trying to make it similar to the one in Sublime Text.
Assume "cmd" as the input string and "command" is one of the results.
To search the files, among other things, I split that input by chars and end up with the following regex: c.*?m.*?d. This part is succesfull in finding files like "command", however, when I use the same regex to replace the found string with some HTML elements to evidentiate the fact that the searched string is found in that particular item, this results in something like this:
<span>command</span>
I understand exactly why this is happening and I'm looking for and alternative to display to the user something like the following:
<span>c</span>o<span>m</span><span>m</span>an<span>d</span>
Or, maybe just:
<span>c</span>o<span>m</span>man<span>d</span>
I have an idea of how to do this, which is by encapsulating every single character in between parantheses and then replace every single one with the <span>$x</span> part, but I'm not sure how to do this exactly.
Any kind of help is immensely appreciated.
Thanks,
Hi I have a Stylesheet where i use xsl:analyze-string with the following regex:
(&journal_abbrevs;)[\s ]*([0-9]{{4}})[,][\s ][S]?[\.]?[\s ]?([0-9]{{1,4}})([\s ][(][0-9]{{1,4}}[)])?
You don't need to look at the whole thing :)
&journal_abbrevs; looks like this:
"example-String1|example-String2|example-String3|..."
What I need to do know is exclude one of the strings in &journal_abbrevs; from this regex. E.g. I don't want example-String1 to be matched.
Any ideas on how to do that ?
It seems XSLT regex does not support look-around. So I don't think you'll be able to get a solution for this that does not involve writing out all strings from journal_abbrevs in your regex. Related question.
To minimize the amount of writing out, you could split journal_abbrevs into say journal_abbrevs1, journal_abbrevs2 and journal_abbrevs3 (or how many you decide to use) and only write out whichever one that contains the string you wish to exclude. If journal_abbrevs1 contains the string, you'd then end up with something like:
((&journal_abbrevs2;)|(&journal_abbrevs3;)|example-String2|example-String3|...)...
If it supported look-around, you could've used a very simple:
(?!example-String1)(&journal_abbrevs;)...
It happens all the time, I would need to scan my code for places where I have two or more of the same keywords.
For example $json["VALID"]
So, I would need to find json, and VALID.
Some places in the code may contain:
// a = $json['VALID']; // (note the apostrophes)
(I am using EditPlus which is a great text editor, letting me use regex in my searches)
What would be the string in the regex to find json and VALID (in this example) ?
Thanks in advance!
Use this regex:
\$json\[["']VALID['"]\]
wound find $json<2 character>VALID
\$json.{2}VALID
I'm looking for a regular expression that can find and replace all the text "anytext" with "anything" in netbeans, some of the symbols also contain this text. I've done it a while back for a single file but now I want to change everything in my application & I'm struggling to get it right.
Just use find & replace to replace all instances of "anytext" with "anything". There is no difference between this and a regex find & replace, because there doesn't exist a pattern that can be easily exploited using regex. There is no difference in this case. Based on your comment, you still must manualy enter the word you want replaced and a word that will replace it.
I think you have misunderstood a bit what regular expressions are all about.
Were you looking for something like this? Where it wouldn't grab it inside word?
\banytext\b