Tutorial by Examples

Back references are used to match the same text previously matched by a capturing group. This both helps in reusing previous parts of your pattern and in ensuring two pieces of a string match. For example, if you are trying to verify that a string has a digit from zero to nine, a separator, such as...
Problem: You need to match text of a certain format, for example: 1-a-0 6/p/0 4 g 0 That's a digit, a separator (one of -, /, or a space), a letter, the same separator, and a zero. Naïve solution: Adapting the regex from the Basics example, you come up with this regex: [0-9]([-/ ])[a-z]\...

Page 1 of 1