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

IsValid regular expression question

Contributor ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

Would one of the following validate this input? Space/blank giving me trouble. Have tried :space: and :blank: also. Shouldn't the /s detect a blank space in the string?

<cfset y = " ">
<cfoutput>
<cfif IsValid("regular_expression", y, "[a-zA-Z0-9 ]+")>
1)#y#
</cfif>
<cfif IsValid("regular_expression", y, "[a-zA-Z0-9\s]+")>
2)#y#
</cfif>
</cfoutput>

TOPICS
Advanced techniques

Views

297

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
Advocate ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

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
Contributor ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

Sorry about that, typo. I've corrected the code. But - still no luck. Any suggestions?

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
Advisor ,
Jun 19, 2006 Jun 19, 2006

Copy link to clipboard

Copied

LATEST
This is a bug with how CF interfaces to java's regex.
File a bug report.

The code below shows how bad the bug is plus a java work around.

<cfif IsValid ("regex", y, ' ')>
3 )#y#
</cfif>

<CFSET oPattern = createObject ("java", "java.util.regex.Pattern").compile ("[a-zA-Z0-9\s]+")>

<cfif oPattern.matcher (y).find ()>
4 )#y#
</cfif>

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