Wednesday, 15 July 2015

regex - regular expression multiple matches -


For reference, this is the regex tester I am using:

I How to modify this regular expression: To get several sub-matches for the following test string: <^ >> [^;] +

 ; First; second; Third; Fourth; Fifth and sixth; Seventh;  

I currently only get a sub-match:

  first  

Actually, - I want to ; Consistent with the content between the characters, I am expecting a sub-match list like this:

  First Second Third Fourth Fifth and Sixth Seventh   

However, this motivates me to solve my problem in a little different way. I came up with this regular expression that still gives only a match, but the number near the end works as the index for the desired match, for example:

  ( ?: ([^;] +)) {5}  

My exam matches the string with this question:

  Fifth and sixth < / Code> 

However this solution allows me to achieve what I want - though in a different way - the correct answer to my question is Found in Ha's comments more specifically to:

I can how regular expressions modified to get all over-the-match?

The answer is, you can not modify

But I specifically targeted rsyslog regular expression system.


No comments:

Post a Comment