Adrien Ruffie wrote:knowing I can choose/switch different pattern, example instead "[Ref ticket: $$token$$]", "[Reply to Ref: $$token$$ for ticket]" and also $$token$$ can be change ...
Steve Luke wrote:
So don't look for the god-regex, instead look for a simple regex for each individual pattern / situation.
People want one pattern to match many different situations. I would suggest not doing that. You will find it a lot easier if you come up with a set of limited RegEx patterns (one for [Ref ticket: ...] another for [Reply to Ref: ... for ticket], etc...)
Adrien Ruffie wrote:It's not my decision, is just the project specification ... and no I can limite regex patterns sorry.
Adrien Ruffie wrote:
Doesn't work because the regular expression take in account that the last part is the closed bracket ...
Adrien Ruffie wrote:Great thank, it work correctly :-)
But I'am interesting by your advices:
And even if it's so, there is still a lot you can take from Steve's advice:
break down the string into simple patterns to perform the individual pieces of the process.
concatenate them together - maybe surrounded by brackets to create groups - to get your full regex.
but isn't the solution you give me in the last code snippet ?
Because I think it done correctly my needs:
1] check if subject like maybe one provided
2] If subject as maybe same, extract the token
Adrien Ruffie wrote:Example I have following code:
Adrien Ruffie wrote:Ok sorry for the problem
A very good classe example, it work very well, but just a question why I can replace %%token%% by $$Token$$ ?
It give me an array bound exception, '$' charater is special in regex ?