Saturday, 27 August 2016

Regex match and grouping



Here's a sample string which I want do a regex on




101-nocola_conte_-_fuoco_fatuo_(koop_remix)


The first digit in "101" is the disc number and the next 2 digits are the track numbers. How do I match the track numbers and ignore the disc number (first digit)?


Answer



Do you mean that you don't mind what the disk number is, but you want to match, say, track number 01 ?



In perl you would match it like so: "^[0-9]01.*"
or more simply "^.01.*" - which means that you don't even mind if the first char is not a digit.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...