Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.