If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.
Post a reply to the thread: How do I delete everything after a certain characters in Perl?
Click here to log in
What is the number after 87?
You may choose an icon for your message from this list
Will turn www.example.com into [URL]http://www.example.com[/URL].
You may rate this thread from 1-star (Terrible) to 5-stars (Excellent) if you wish to do so.
How do I delete everything after a certain characters in Perl? I need to delete everything that comes after certain characters, with exception to the new line, in my code. In other words, if my special character was '{' and my code read Eating Food {feat. john kong} (Remix) After deletion, it would now read Eating Food Now here comes the tough part. I need to do this with multiple characters, being: ( / \ [ ^ - ~ _ " * ' So if I had multiple lines of code: Eating Food *feat. john kong* (Remix) Eating Food (feat. john kong) (Remix) Eating Food ~feat. john kong~ (Remix) Eating Food _feat. john kong_ (Remix) Eating Food 'feat. john kong' (Remix) Eating Food "feat. john kong" (Remix) etc.. After deletion would print out the same thing as the first deletion. I tried $line =~ s/[(/\[^-~_"*'].*$//; but I keep getting an invalid [] range error Is it possible to do this in one line of code?
How do I delete everything after a certain characters in Perl?
Forum Rules