I have a string which is combination of letters and digits. For my application i have to separate a string with letters and digits: ex:If my string is "12jan" i hav to get "12" "jan" separately..
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- how to split a list into a given number of sub-lis
- Can php detect if javascript is on or not?
You can make use of
preg_split
to split your string at the point which is preceded by digit and is followed by letters as:Code in Action
Result:
Of course, this only works when your strings are exactly as described "abc123" (with no whitespace appended or prepended).
If you want to get all numbers and characters, you can do it with one regex.
See it!