regex - Issue with matching -


the following code below trying match format

[a=>]b[->c][d:e]

where a=>, ->c, d:e optional.

($reg =~ /^      (?:([\w\/]+)=>)?       # (optional)      (\w+)                  # (required)      (?:->(\w+))?           # (optional)      (\[\d+\]|\[\d+:\d+\])? # (optional)      .$/x)         or croak ("-e invalid register format ); 

when give input sample=>status $reg value, last s of status getting truncated. why?

the regex symbol . before $ line-end symbol captures "one thing" in case, seems last letter s

this means regex right, "one thing" needed satisfied regex, regex matcher rewound required (\w+) pattern 1 character give . demanded character.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -