CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Corrected - Please read again: Regexp to remove a matched pattern but...: Edit Log



Chupo_cro
Novice


Aug 25, 2012, 5:19 AM


Views: 8092
Corrected - Please read again: Regexp to remove a matched pattern but...

Can someone, please, help me to construct the regexp to remove the matched pattern from the string, but to avoid more than one space in the resulting string at the boundaries of the removed substring. All of the remaining substring should stay untouched.

Note: The blue text is a condition I forgot to insert in the inital text.

Example:

Code
Input: 

one two some_pattern three four
one two some_pattern three four
one twosome_pattern three four
one two some_patternthree four
one two three four some_pattern
some_pattern one two three four
onetwosome_patternthreefour
one two some_pattern three four

Desired output:

one two three four
one two three four
one two three four
one two three four
one two three four
one two three four
onetwothreefour
one two three four


Just removing the

Code
some_pattern

from the

Code
one two some_pattern three four

would result in the string

Code
one two  three four

which has two consecutive spaces.
Chupo_cro

(This post was edited by Chupo_cro on Aug 25, 2012, 9:34 AM)


Edit Log:
Post edited by Chupo_cro (Novice) on Aug 25, 2012, 6:39 AM
Post edited by Chupo_cro (Novice) on Aug 25, 2012, 6:42 AM
Post edited by Chupo_cro (Novice) on Aug 25, 2012, 9:30 AM
Post edited by Chupo_cro (Novice) on Aug 25, 2012, 9:34 AM
Post edited by Chupo_cro (Novice) on Aug 25, 2012, 9:34 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives