Jump to content

[SOLVED] explanation of code?


ali_2kool2002

Recommended Posts

Guest prozente

|^sub_([\d]+)\z|

| is the pattern delimiter
^ means from the start of the string
sub_ is some text it wants to match from the start of the string
() are used to create back references, it'll capture this text in the returned array
[] are used to define a character class
\d stands for decimal digit, it'll match numbers 0-9, so this is the character class
+ means the character class will match at least one char for a char class
so ([\d]+) will be returned as the first back reference
\z stands for the end of the string

 

so sub_123 will pass this regex and return 123 as the first back reference

sub_abc1 will not pass this regex as it has the alpha characters in it

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.