HELP: deactivating regexp-active chars from string? 
Author Message
 HELP: deactivating regexp-active chars from string?

Hello!

me again :D

just wondering if there is allready some availbale func to deactivate
regexp active chars from a string (those are '.[]/()' etc...)

because i test a usergiven entry against some intern data, thus if the
user inserts eg [] into his chain, thos signs get interpreted as a range
delimiter..

now i can make my own function to deactivate those chars in a string,
  but i bet someone allready did so ...

--
ciao bboett
==============================================================

http://www.*-*-*.com/ ~bboett http://www.*-*-*.com/ ~bboett



Mon, 10 May 2004 18:16:41 GMT  
 HELP: deactivating regexp-active chars from string?

Quote:

> just wondering if there is allready some availbale func to deactivate
> regexp active chars from a string (those are '.[]/()' etc...)

> because i test a usergiven entry against some intern data, thus if the
> user inserts eg [] into his chain, thos signs get interpreted as a range
> delimiter..

> now i can make my own function to deactivate those chars in a string,
>   but i bet someone allready did so ...

Yup.  Use \Q ... \E around the text you want to protect:

 kevin% perl -e 'print "[]\n"'
[]
 kevin% perl -e 'print "\Q[]\E\n"'
\[\]

This is in perldoc perlre.

--
Kevin Michael Vail | a billion stars go spinning through the night,

. . . . . . . . .  | But _in_ you is the presence that
 . . . . . . . . . | will be, when all the stars are dead.  (Rainer Maria Rilke)



Mon, 10 May 2004 18:34:35 GMT  
 HELP: deactivating regexp-active chars from string?

Quote:

>just wondering if there is allready some availbale func to deactivate
>regexp active chars from a string (those are '.[]/()' etc...)

   perldoc -f quotemeta

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Mon, 10 May 2004 19:04:26 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. regexp for strings of chars

2. regexp: matching at least n chars out of a string of length m

3. reading char by char in a string

4. Char position of 1st non-word char in a string

5. Appending char to strings by char

6. split a string not only by a single char but also by a string

7. Newbie: sprintf ('%-20s', 48 char string) returns 48 not 20 length string

8. Help: bol regexp in split string

9. HELP/QUES: regexp and strings

10. regexp to negate 2 chars at once

11. RegExp Char Class

12. Regexp char class: mixing ranges and negation?

 

 
Powered by phpBB® Forum Software