What you need is probably something like this:
- Code: Select all
^(\d+)\. (.*)$
Group 1 will be the number, without a dot, group 2 will be the course name, all the way to the end of the string. To elaborate a bit:
"^" Anchors the expression at the start of the string. This means the regex engine won't try to find partial matches starting halfway through a string.
"(\d+)" Specifies a capturing group. "\d" matches any digit, shorthand for "[0-9]". Then we have a "+", which says to match one or more of the preceding tokens, which was the digit in this case. As soon as the engine meets a character that's not a digit, the capturing group is complete and we move on.
"\. " Matches the literal character ".", followed by a space. Without the "\" in front, the engine will interpret "." as a wildcard and match any character, which in this case might not be what you want. If some course numbers don't have the dot after the number, making the dot optional like "\.? " might work better here.
"(.*)$" Is the second capturing group. The ".*" is a wildcard dot that matches any character, followed by the star "*", which will tell the engine to match 0 or more of the preceding dot character. This will keep matching any character until it hits the "$" anchor, which means "end of string".