Skip to main content
December 11, 2010
Pregunta

RegEx for characters with accents and such but not alphanum or punctuation

  • December 11, 2010
  • 3 respuestas
  • 830 visualizaciones

I'm creating a fuction that checks for the following code snip. I'm having trouble understanding what I need to do to get the last criteria. How do I specifically check for characters with additional marks  such as   a'   but  not  a

Thanks in advance for any help or advice you might give

    <!---Contain characters from three of the following five categories:--->
         
            <!---English uppercase characters (A through Z)--->
   <cfif ReFind("[[:upper:]]+",passwd,0, false) gt 0>
    <cfset numCharSets = numCharSets + 1>
   </cfif>
           
            <!---English lowercase characters (a through z)--->
   <cfif ReFind("[[:lower:]]+",passwd,0, false) gt 0>
    <cfset numCharSets = numCharSets + 1>
   </cfif>
           
            <!---Base 10 digits (0 through 9)--->
   <cfif ReFind("[[:digit:]]+",passwd,0, false) gt 0>
    <cfset numCharSets = numCharSets + 1>
   </cfif>
           
            <!---Non-alphabetic characters (for example, !, $, #, %)--->
   <cfif ReFind("[[:punct:]]+",passwd,0, false) gt 0>
    <cfset numCharSets = numCharSets + 1>
   </cfif>
           
            <!---A catch-all category of any Unicode character that does not fall under the
      previous four categories. This fifth category can be regionally specific.--->

    Este tema ha sido cerrado para respuestas.

    3 respuestas

    December 11, 2010

    Well I guess I may have been overthinking it. Here is my solution. Let me know if anyone sees a problem with it.

    ReFind("[^[:alnum:][:punct:]]+",testStr,0, true)

    ilssac
    Inspiring
    December 11, 2010

    More information about Unicode Regex

    http://www.regular-expressions.info/unicode.html

    And one about doing so in ColdFusion

    http://stackoverflow.com/questions/531461/how-do-you-reference-unicode-characters-in-coldfusion-regex

    What fun one can have with internet searches.

    December 11, 2010

    Thanks for your reply. I did indeed do a search and found those pages. I was trying to use /X, but it still finds  a   and   a'

    I thought maybe someone might have experience with this particular case on the forum.  It doesn't seem like an extraordinary case. I certainly didn't want to add what seems like and infinite number of codes for each explicit example.

    ilssac
    Inspiring
    December 11, 2010

    AWEInCA1 wrote:

    How do I specifically check for characters with additional marks  such as   a'   but  not  a

    By recognizing they are seperate characters.  You will probably want to use codes to access these characters.

    \uFFFF where FFFF are 4 hexadecimal digitsMatches a specific Unicode code point. Can be used inside character classes.\u00E0 matches à encoded as U+00E0 only. \u00A9 matches ©

    http://www.regular-expressions.info/refunicode.html

    http://www.regular-expressions.info/reference.html