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:
Matching a special character at begining of line

 



Ram-Z
New User

Aug 10, 2009, 2:42 PM

Post #1 of 2 (2208 views)
Matching a special character at begining of line Can't Post

Hi,
I'm having some trouble with removing a bunch of '+' at the beginning of a string.
I'm using the linux bash command 'rename' which uses pearl regex.

Basically I have some files:

+foo+bar.txt
foo+bar.txt

where I want to remove the + in front and replace any + in the middle with a space.

I tried to remove the first + with:

Code
rename "s/^\+//" *.txt


Code
rename "s/\A\+//" *.txt

and

Code
rename "s/\A\Q+//" *.txt

but everything returns:

Code
Unknown option: e 
Unknown option: e
Unknown option: e
Usage: rename [-v] [-n] [-f] perlexpr [filenames]

with "e" being the first letter after the + of the three files starting with +

Any help would be appreciated


Ram-Z
New User

Aug 11, 2009, 7:49 PM

Post #2 of 2 (2189 views)
Re: [Ram-Z] Matching a special character at begining of line [In reply to] Can't Post

Nervermind, it wasnt regex related. Linux was considering the file names as another argument...

Fixed it with:

Code
rename 's/^[+]//' -- *.txt


 
 


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

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