How to extract only alpha characters

Results 1 to 2 of 2

Thread: How to extract only alpha characters

  1. #1
    Join Date
    Dec 1969

    Default How to extract only alpha characters

    I want to open a URL from some java code.<BR>The URL passed in is used as the link as well as the target to,target);<BR>Unfortunately there are many characters that can not be in the target that exist in typical URLs eg "./?{}&"<BR>I started by creating a RE which filtered these out and replaced them with "_" but I am worrried I could have missed some characters.<BR>So I want a RE which replaces any non alpha characters with "_".<BR>I Tried "/![a-z][A-Z]/g" but that didn&#039;t work. What is the "not" command in regular expressions ?

  2. #2
    Mike (original poster) Guest

    Default RE: How to extract only alpha characters

    re = /[ -@[-`{-~]/g;<BR>seems to work but it still would be nice to know how to exclude characters not in a particular set.<BR><BR>%&#062;&#060;Script language="JavaScript"&#062;&#060;!--<BR> function URLPreview(URL) {<BR> var target;<BR> var re;<BR> <BR> re = /[ -@[-`{-~]/g;<BR> target = URL.replace(re,"_");<BR> //alert(target);<BR>;http://&#039;+URL, target);<BR> return false;<BR> }<BR> //--&#062;<BR>&#060;/Script&#062; &#060;%<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts