php - Dividing words into 2 parts: letters and numbers -
there strings:
$string1 = "text3256"; $string2 = "23pt"; i somehow check if word belongs pattern "numbertext" or "textnumber" purpose of splitting word 2 parts: "number" , "text"
in example above - words shall divided following:
"text3256" -> "text" , "3256" "23pt" -> "23" , "pt" is possible create such regex pattern? (words such "text32text" or "44fd675" shall not divided)..
i can create hardcode solution using "each character iteration" approach , checking if next character letter or numeric.. that's hardcore, so, wondered if me out better, easier solution?
you can use:
'/^(?:(?:([a-z]+)(\d+))|(?:(\d+)([a-z]+)))$/i'
Comments
Post a Comment