regular expression to match inside parentheses [closed] - regex

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to do the following match and capture the group
(inside),(inside),...,(inside)
or
(inside)
That is, either the same inside appears multiple times inside parentheses and separated by a comma, or it only appear once inside parentheses.
The capture group is the stuff inside. Could anybody help me?
Thanks.
change
Sorry that I did not make it clear. The stuff inside may contain parentheses, but not comma. That is the way it is distinguished.

Use a back-reference to test that the same string is repeated.
/^\(([^,]*)\)(?:,\(\1\))*$/
DEMO

Related

Regex match every occurance and wildcard condition [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
How can I write a regex that will match the following conditions:
Where every instance of the occurance 'eVar7=' contains the following 'unav'
This should be false:
;AA;;;;eVar7=nr_unav,;AA;;;;eVar7=br_unavail,;AA;;;;eVar7=sugg,;AA;;;;eVar7=sugg,;AA;;;;eVar7=sugg
and this should return true:
;AA;;;;eVar7=nr_unav,;AA;;;;eVar7=br_unavail,;AA;;;;eVar7=nr_unav,;AA;;;;eVar7=nr_unav11,;AA;;;;eVar7=nr_unavasdfasdferwgf
This regex does the opposite. If there is a match means that you don't want it:
eVar7=(?![^;]*?unav)
It uses a negative lookahead. Meaning that after the eVar7 match there should not be something with "unav" in the middle. If so, it matches.
This is just to put you on the right track however as there are a lot to consider with your examples. For example where exactly should this "unav" pattern exist. What characters are allowed between eVar7 and "unav" etc. Feel free to change the regex to suit your needs.

regualr expression letters and word match [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
apologies for what is probably a really simple question but I am a complete noob when it come to using regular expressions.
I am trying to create an expression that matches some set criteria together, and although I can find the code to validate these things separately I'm struggling to understand how you put it all together.
What I am looking for is an expression that validates an entered code:
It will always a start with either OR or TR and then you will have 6 digits after that e.g. TR002563
Any help would be greatly appreciated.
Try this regex:
/^(?:O|T)R[0-9]{6}$/
You can use this regex:
/^[OT]R[0-9]{6}$/

How to start a RegEx statement at the 2nd position of a string [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a string
.HACK G.U. VOL. 1 REBIRTH
I'm using a tool that allows me to specify a RegEx statement that can be used in a replace operation.
I want the RegEx to find all the periods "." that start after the 1st position. The replace operation should return the following.
.HACK GU VOL 1 REBIRTH
Thanks
The following will do the trick:
(?<!^)(\.)
per http://rubular.com/r/w1apzTZLPk
Since Javascript doesn't support negative lookbehind, this can't be done in Javascript, but there are alternatives as discussed in http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript
One approach in this case would be to capture the previous character and replace it with the same content as part of the replacement process, as in:
(.)(\.)
Note: You don't need to use a capture group for the matching of the literal . in either of the above. I just used that technique to highlight the match in Rubular.

regex match anything between {esbmsg:header:xxxxxx} [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
How to match anything between {esbmsg:header: and }
like xxxxxx could be any string {esbmsg:header:xxxxxx}
Try with:
{esbmsg:header:([^}]*)}
Where [^}]* matches everything that is not } character.
Try this regex
{esbmsg:header:(.*)}
It will also allow you to have any character in value.
Well, if you want to capture only the content of your expression (the "xxxxx" part) the best approach is to use positive look ahead:
(?<={esbmsg:header:)[^}]+
Depending on how your content looks you might have to tweak the [^}] part. For further information on regex (or a detailed explanation of the expression above) I recommend the following:
Regex reference
Regex tutorial

I'm confused by a simple regex: I need to match something like [Test] but not Test [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
How would I go about writing a regex to match the first example, but not the second?
Thank you --
Try
\[Test\]
You need to escape the [ and ] as they indicate range start/end.
[] are special characters for a regex, used for defining a character class, therefore escape them with backslashes.
\[Test\]
If you use [Test], it will match a single character which is either T, e, s or t.