Reputation: 1495
I currently have a field that looks like this.
item description is blah ablha blabh albhalbh #thisisitemnumber x/skid)
I am trying to extract the #thisisitemnumber
portion. I currently have this:
'/(#.*\S)/'
But using that I get everything after the "#" even the whitespace. Any help is appreciated!
Thanks :)
Upvotes: 1
Views: 77
Reputation: 66964
You are matching any char .
any number of times *
until non-space \S
. This isn't really what you want. Also, since *
is greedy it scoops up everything up to the last non-space in the string.
You want non-space one or more times:
/(#\S+)/;
This presumes that there should be something after #
, thus the +
Upvotes: 3