Jump to content

Recommended Posts

I have an error with this statement:

[code]preg_match("[0-9]+\.?[0-9]*", $text_string, $match_array);[/code]
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: preg_match(): Unknown modifier '+' in ...[/quote]
I thought it had something to do with the slashed in php strings, but I have not been able to get it right.

Any thoughts?
Link to comment
https://forums.phpfreaks.com/topic/6013-preg_match-error/
Share on other sites

[quote]
Would this regex be the way to go if I wanted to pull out the number value from this example?:

<b><i>$456.50</i></b>

And have preg_match pull out "456.50" ?
[/quote]
If the string will only contain one number then it should be fine. The regex will match a number that ends with a "." however, which may not be what you want. You could change it to the following to avoid that.
[code]
/[0-9]+(.[0-9]+)?/
[/code]
Link to comment
https://forums.phpfreaks.com/topic/6013-preg_match-error/#findComment-21650
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.