I am new to Regex and I am looking to write a Regex to extract any kind of numbers (like 23,23a,24-26) which are immediately followed by a text which is surrounded by !.
More explanation: Need to match numbers (simple numbers, the range of numbers separated by a dash or a number followed by a letter (a,b,c,d,..)) that are immediately followed by itself (ignoring commas) and a text surrounded by !
For example in the below text, I am looking for the part which I made Italic
; 46-58 !some text! ; , 5 some text, 3-21 , 6-22 some text, 16 some text !some text! ; 46-58 some text, 5 !some text! ; 3-21 , 6-22 some text, 16 some text, some text !some text! ; 46-58 some text, 5 some text, 3-21 ,23a , 6-22 !some text! ;
To make it clearer, I made the text that I am interested Red.
So far I came up with the following Regex
\![\w\s]*\!
=> find the text surrounded by !
[a-z]?[\s|,]? [\-|,| | | | | |0-9|-|\d+[\-|a-z]*\d*]*\![\w\s]*\!
=> this one select everything between two consecutive ;
\d+[-,]*[a-z]*\d+[a-z]*\s*[,]*
=> this one select any kind of numbering
But so far, I was not able to put them together to select what I want.