Regex - preg_replace php - Understading -


i have following code i'm trying understand code does, after several time didn't figure out...

obs: code made long time ago , working treat inputs user, such city, state , etc.

preg_replace('/\a[\w\.\-\+]+\z/', '', $anystring) 

what know:

\a = match @ beginning of input

\w = match word

\. , \- , \+ = match character . , , +

\z = match end of string

any appreciated, thanks

\a     - start @ beginning   [    - match of following:     \w   - word character (a-z, a-z, 0-9, underscore)     \.   - dot     \-   - dash     \+   - plus   ]   +     - @ least 1 time, possibly more. \z     - end @ end 

so entire string, start end, must composed of letters, digits, underscores, dots, dashes or pluses , must @ least 1 character long.

if is, replace empty string (i'm curious why useful).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -