Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: regex to remove all non a-z and spaces

by coldfingertips (Pilgrim)
on May 16, 2005 at 04:19 UTC ( #457360=note: print w/replies, xml ) Need Help??


in reply to Re: regex to remove all non a-z and spaces
in thread regex to remove all non a-z and spaces

This regex isn't exactly working for me.
$cleaned_search =~ s/[^a-z0-9 ]+//gi;
I keep getting files named "this+is a test.html", "the+farmer saves the day" and "i+hate this stuff.html".

I thought it was the + so I removed it and the regex is still adding a + sign in my string when it wasn't there before. I also can't add any weird characters because it errors out when it tries to create the file. IE: if I used \ it said it failed to open on a closed filehandle or something.

So it seems this regex isn't working at all.

Replies are listed 'Best First'.
Re^3: regex to remove all non a-z and spaces
by muntfish (Chaplain) on May 16, 2005 at 08:56 UTC

    There's no way that statement on its own would add a + sign.

    I think you need to give us a bit more context in order to find the cause of the problem: a few more lines of your code; what your input looks like; what your output looks like; and what you expect your output to look like...

    Then we'll be able to help you out, hopefully.


    s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://457360]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2020-02-21 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (94 votes). Check out past polls.

    Notices?