Regex exclude bracket symbol - regex

I am trying to use RegEx to find all cells in OO-calc with : [RB]Condition=New
the RB part is necessary, as other cells may get caught if it is not specified.
the RegEx that would work would be : [RB]Condi.*
however the brackets are read as a part of the expression, is there any way to fix this?

Use an escape character to treat it as an actual character. For example \[ would find all [. I think the Regex you're looking for is \[RB\]Condition=New*. The original Regex you had would find RCondition=New and BCondition=New.
*I'm not familiar with OO-calc, so I'm not entirely sure I understand what you mean.

Related

Brackets within a Regex string

I'm trying to use a regular expression to match on a string. Brackets are special characters within regex, am I'm unsure of how'd i'd go about including them in my regex.
To provide more context, I want to find a string such as test[test]
My regex currently looks like this: ^*test[test]. My expression is built out more much than this, but this example is enough to understand the problem.
How can i search for brackets in my string without triggering a character class. I need to use a regex, please don't recommend switching to something else.
You can escape a character with a backslash so \[
I can highly recommend https://regex101.com/ to test your regex without having to code it.
Try: ^.*test\[test\] - This mean {start of line}, {anything}, "test[test]".

regexp, Extract value between parentheses

example:
"today [(["hi"],{"my"})],["ok"],("good")),(["gg"],["fire"])] nice game [(["1"],{"2"})],["3"],("4")),(["5"],["6"])] end."
->
[(["hi"],{"my"})],["ok"],("good")),(["gg"],["fire"])]
[(["1"],{"2"})],["3"],("4")),(["5"],["6"])]
In this case, there is a noise in the middle.
It doesn't work in the usual way
Please give me an idea of extracting the value between parentheses in another way
I love regex, almost as much as I hate them. Writing an effective regex can take a problem from impossible to trivial.
Knowing how to iterate one is very important. Let me teach a man to fish.
Consider using an online regex tool: https://regex101.com/
Input your string:
image of me adding in the text
Then try to Match it. I did with the following \([^()]+\)
That is:
escape the parenthesis you want to match on \( and \) because they are special symbols.
You know you want to match everything that isn't a parenthesis between them. So I use a no-match clause by doing [^...] where the elipsis are all the characters I don't want to match. I then add my parenthesis raw in there [^()]
Finally. I want to have 1 or more of those so I use +.
Thus I have my awnser.
image of me matching the text
edit: cannot post images because of rep

Regex Match between brackets (...)

I'm trying to grab 2 items from a simple line.
[Title](Description)
EDIT: actually a url looking to display called it description because i want it displayed not actually parsed.
[Trivium](https://www.youtube.com/user/trivium)
Grabbing between the brackets (...) doesn't seem to work at all for me. I've googled and found several variations with no luck, Thanks in advance :)
EDIT:
Tried the following:
[(.+?)]\((.*)\)
[(.+?)]\([^\(\r\n]*\)
[(.+?)]((.+?))
and a cpl more I cant find again
The first regex you listed almost has it right. Try using this regex instead:
\[.+?\]\((.*)\)
As #PM 77-1 pointed out, you need to escape the brackets by placing a backslash in front of them. The reason for this is that brackets are special regex metacharacters, or characters which have a special meaning. Brackets tell the regex engine to look for classes of characters contained inside of it.
Your original regex [(.+?)]\((.*)\) is actually doing this:
[(.+?)] match a period '.' 1 or more times
\((.*)\) match (anything), i.e. anything contained in parentheses
So this regex would match .....(stuff) but would not match [Title](Description), the latter which is what you really want.
Here is a link where you can test out the working regex:
Regex 101

eclipse search and replace with wildcard

I am trying to remove all occurances of id="someId" where someId is different in every case. I have tried to use this syntax: (id="\w+\"\(\)) because it's used in similar situations by other posters. But I don't understand the syntax and of course it doesn't work.
Could someone tell me why this syntax is incorrect and maybe point me to a resource that explains the syntax?
Check "Regular expressions" check box.
The expression is
id\s*=\s*"[^"]+"
\s* means space, * means zero or more
[^"] means anything but quote, + means one or more
To capture the string use "([^"]+)" and $1 in the replace with field.
More info at http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

How to search (using regex) for a regex literal in text?

I just stumbled on a case where I had to remove quotes surrounding a specific regex pattern in a file, and the immediate conclusion I came to was to use vim's search and replace util and just escape each special character in the original and replacement patterns.
This worked (after a little tinkering), but it left me wondering if there is a better way to do these sorts of things.
The original regex (quoted): '/^\//' to be replaced with /^\//
And the search/replace pattern I used:
s/'\/\^\\\/\/'/\/\^\\\/\//g
Thanks!
You can use almost any character as the regex delimiter. This will save you from having to escape forward slashes. You can also use groups to extract the regex and avoid re-typing it. For example, try this:
:s#'\(\\^\\//\)'#\1#
I do not know if this will work for your case, because the example you listed and the regex you gave do not match up. (The regex you listed will match '/^\//', not '\^\//'. Mine will match the latter. Adjust as necessary.)
Could you avoid using regex entirely by using a nice simple string search and replace?
Please check whether this works for you - define the line number before this substitute-expression or place the cursor onto it:
:s:'\(.*\)':\1:
I used vim 7.1 for this. Of course, you can visually mark an area before (onto which this expression shall be executed (use "v" or "V" and move the cursor accordingly)).