• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Parse String using RegEx REMatch

Guest
Sep 22, 2013 Sep 22, 2013

Copy link to clipboard

Copied

Why does this not return the variable form.item_cost to equal:199.99?

<CFSET string1 = "Here we have $199.99 is the price">

<CFSET form.item_cost = "#reMatchNoCase("^\d{0,4}(\.\d{1,2})?$",string1)#">

I only want to match the first price it sees in the string and return that value as a numeric decimal.

Views

658

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 22, 2013 Sep 22, 2013

Because you're anchoring the regex to the beginning and end of the string with ^ and $, you'll only match if the string in its entirey is the number.

I recommend using regex coach for testing this sort of thing. It makes it very easy to work this sort of thing out. http://www.weitz.de/regex-coach/

--

Adam

Votes

Translate

Translate
LEGEND ,
Sep 22, 2013 Sep 22, 2013

Copy link to clipboard

Copied

LATEST

Because you're anchoring the regex to the beginning and end of the string with ^ and $, you'll only match if the string in its entirey is the number.

I recommend using regex coach for testing this sort of thing. It makes it very easy to work this sort of thing out. http://www.weitz.de/regex-coach/

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation