please rate
this thread
  •  
  • Subject
  • Author
  • Date
Posted by Jim Thompson on June 5, 2009, 3:45 pm
  I'm an amateur at regular expressions :-(

I know I can search for...

'[a-zA-Z0-9\+\-\.\*\/\(\)\_]+'

and my editor (UltraEdit) will highlight...

'some_text_characters_and_math_operators'

I want to do a replace operation such that I get...



(In other words just change the opening and closing characters)

How do I do that?

(UltraEdit supports Perl, Unix and their own flavor of regular
expression language.)

Thanks!

                                        ...Jim Thompson
--
| James E.Thompson, P.E.                           |    mens     |
| Analog Innovations, Inc.                         |     et      |
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    |
| Phoenix, Arizona  85048    Skype: Contacts Only  |             |
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  |
| E-mail Icon at http://www.analog-innovations.com |    1962     |
            
 Stormy on the East Coast today... due to Bush's failed policies.

Posted by DJ Delorie on June 5, 2009, 4:06 pm
 

Depending on what regex compiler it uses, either this:



or this:

\

By default, regex's match characters as-is, but if the compiler
interprets a character as special (like + or ]) you put a backslash in
front of it to mean "match this character as-is".

Note that some regex compilers do the opposite for some characters;
for example Emacs's () are regular characters, but \( and \) are
special grouping operations.  So either read the manual, or just try
both ways.

Posted by Jim Thompson on June 5, 2009, 4:22 pm
 

Both approaches replace 'desired_text' with
    :-(

I need to retain the desired_text.

                                        ...Jim Thompson
--
| James E.Thompson, P.E.                           |    mens     |
| Analog Innovations, Inc.                         |     et      |
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    |
| Phoenix, Arizona  85048    Skype: Contacts Only  |             |
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  |
| E-mail Icon at http://www.analog-innovations.com |    1962     |
            
 I love to cook with wine     Sometimes I even put it in the food

Posted by DJ Delorie on June 5, 2009, 6:26 pm
 

Ah, I missed that part.  Sorry.

Yeah, substitutes for whatever the (...) matched.

Posted by Jim Thompson on June 5, 2009, 6:28 pm
 

I'm learning.  I have several cookbooks, but I think I need a good
introductory text.

                                        ...Jim Thompson
--
| James E.Thompson, P.E.                           |    mens     |
| Analog Innovations, Inc.                         |     et      |
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    |
| Phoenix, Arizona  85048    Skype: Contacts Only  |             |
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  |
| E-mail Icon at http://www.analog-innovations.com |    1962     |
            
 I love to cook with wine     Sometimes I even put it in the food