substitute/regex etc



how can i substitute, or remove anything that's not an alphanumerical
character in a string?

i.e:
$string = "AbCdEF1246Hfn \n";
$string =~ s/[^a-z][^A-Z][^0-9]//g;

though to me, that would say:
(replace anything that's not a lower case letter as the first char) then
(replace anything that's not an upper case letter as the second char) then
(rpelace anything that's not a number as the third char).

or is this right?

thanks, dan


.



Relevant Pages

  • Re: finding strings in a text file help
    ... digits and reserved words and then prints them out in order ... > it gets the whole string matches it against the reserved words array ... one character of a potential word in your "s" string. ... a char[] array would do. ...
    (comp.lang.java.help)
  • Re: remove spaces from a string and Complexity
    ... string character by character and copying onto another output string. ... void delchar(char *s, char c) ... I've seen functions written as above, however I'm still a little confused about one point - C passes by value therefore with your above function wouldn't the following behave incorrectly (incorrectly as in not modify the contents referenced by the first parameter but instead modify a copy of it): ...
    (comp.lang.c)
  • Re: "Read stuff from a file and chop it up to do stuff" code advice wanted.
    ... ;; This function returns TRUE if any character ... (if (char< char #\!) ... a stream and an array to hold characters in temp memory. ... ;; resulting string. ...
    (comp.lang.lisp)
  • Re: detecting characters on RS232-Interface
    ... read data into string variable ... > splitted at the end of the receive buffer). ... examine the next char in turn. ... When a character ...
    (microsoft.public.vb.general.discussion)
  • Re: RegQueryValueEx retrieved only one letter
    ... you are declaring this as char *. ... You are expecting telling it to convert an 8-bit character string to Unicode ... Why declare it as char and then cast it to BYTE*? ...
    (microsoft.public.vc.mfc)