php - Problem detecting forward slash in preg_replace regex pattern -


I am running preg_replace in a string that may contain a street number The method I am using is: < / P>

  ([A-Za-z0- 9] *) / i  

This works fine for numbers such as 1, 1a, 123 e.t.c.

Although it does not select the number of road like 1 / 54B

I tried to add a forward slash to the pattern like this:

 < Code> ([a-za-z0-9 \ /] *) / i  

but this number is not picking like a 1/54 b.

Any ideas on what should I use?

Try

  preg_replace ('# ([A-Za -z0-9 /] *) # I ', $ repl, $ subj);  

Using the optional delimiter makes it very easy.


Comments