I am often dealing with list that users submit to a web site. A list usually looks like:
The pattern is usually a number followed by the separator (it can be "-" or "\" or "." or any other typical separators). There can be one or more spaces between the number and separator and between the separator and the list item. Sometimes there is no number in front of the list item and in that case nothing needs to be done. Sometimes there is a number but no separator.
Is there a way to take out the number and/or the separator all together using regular expression?
This will match numbers and separators and the beginning of a line:
^\d+\s*[-\\.)]?\s+
Use it to replace it with an empty strings (depends on the language you are using).
You might have to add more characters to the character class, to match possible separators.
Good source to learn regular expressions: http://www.regular-expressions.info/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With