A,B,C,D,E - How can I get "D" with regex? The fourth position of mached result?
A开发者_如何转开发,B,C,D,E - How can I get "D" with regex? The fourth position of mached result?
I can't set "C,(.*),E" because C and E have dynamic values. Thanks!
This captures D in group 2:
([^,]+,){3}([^,]+),
([A-Z],){3}(A-Z),.*
should work, if you replace A-Z with the actual character classes used (or [^,]
like Sean used above, which matches everything but a comma).
Better to tokenize based on a comma and grab the fourth result, though (assuming the language you're using supports it).
精彩评论