Regular Expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dante

    Regular Expression

    Hello again. I know this is simple but I suck at RegEx.

    Can anyone here provide me with a regex that will filter out
    everything except normal letters? Casing won't matter.

    Thanks so much,
    Dante
  • Andrew Urquhart

    #2
    Re: Regular Expression

    "Dante" <pianoman@reno. com> wrote in message
    news:f05d63b6.0 402231826.332c6 8be@posting.goo gle.com...[color=blue]
    > Hello again. I know this is simple but I suck at RegEx.
    >
    > Can anyone here provide me with a regex that will filter out
    > everything except normal letters? Casing won't matter.
    >
    > Thanks so much,
    > Dante[/color]

    Actually it's a little difficult to know what 'normal letters' means, so I'm
    guessing it means a-z0-9 and whitespace. If so:

    var strTest = "This's a mixture of <em>normal letters</em> and
    !!*£&$(£_\"'#@~ ";
    var strFilteredTest = strTest.replace (/[^a-z0-9\s]/ig, ""));

    If you also want to strip out HTML then use something like the following
    before the above RegExp:

    ..replace(/<\/?[^>]*>/g, " ")

    --
    Andrew Urquhart
    - FAQ: http://jibbering.com/faq
    - Archive: http://groups.google.com/groups?grou...ang.javascript
    - Reply: https://www.andrewu.co.uk/about/cont...=newsgroup_clj


    Comment

    Working...