Hello!
i really like Regex, unfortantly Im not that good at it yet. So therfore I hope you guys can help me out.
The text string I want to validate consists of what I call "segments". A single segment might look like this:
[A-Z,S,3]
So far I managed to build this regex pattern
(?:\[(?<segment>[^,\]\[}' ]+?,[S|D],\d{1})\])+?
it works but it will return matches even though the whole text string contains invalid text. I guess I need to use ^
and $
somewhere in my pattern but I can't figure out how!?
I would like my pattern to produce the following results:
[A-Z,S,3][A-Za-z0-9åäöÅÄÖ,D,4]
OK(two segments)[A-Z,S,3]aaaa[A-Za-z0-9åäöÅÄÖ,D,4]
No matchcrap[A-Z,S,3][A-Za-z0-9åäöÅÄÖ,D,4]
No match[A-Z,S,3][]
No match[A-Z,S,3][klm,D,4][0-9,S,1]
OK(three segments)