RegOops
| From: | Karl DeSaulniers | Date: | Fri, 23 Oct 2015 12:44:16 +0000 |
| Subject: | RegOops | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-325217@lists.php.net to get a copy of this message | ||
Hello all,
With the given string..
vehicle10-vehicle-name
Running regex in a preg_match like
"/(\w+)([0-9+]+)-(.*)/"
I am getting.
array(
0 => vehicle10-vehicle-name
1 => vehicle1
2 => 0
3 => vehicle-name
)
If I change it to.
"/(\D+)([0-9+]+)-(.*)/"
it works as expected.
array(
0 => vehicle10-vehicle-name
1 => vehicle
2 => 10
3 => vehicle-name
)
Why is the \w directive including a digit?
Since when is the number 1 a word??
If anyone could enlighten me, I would greatly appreciate it.
TIA
Best,
Karl DeSaulniers
Design Drumm
http://designdrumm.com