Forum Moderators: coopster & phranque

Message Too Old, No Replies

Regular Expression to Strip Some Simple Stuff Out

I can't work it out even tho it's an easy one.

         

Bennie

2:26 am on Sep 15, 2006 (gmt 0)

10+ Year Member



Howdy Guys and Gals,

I am building a rather large list of KW's.

eg. freelance journalism (760000) freelance journalism jobs (307000) freelance journalism course (26700) freelance journalism uk (176000)

What's a simple RegEx to Strip the (9000random#) out and replace with a line break? ie.

freelance journalism
freelance journalism jobs
freelance journalism course
freelance journalism uk

I have learnt a few and I know I could use homesite, but I want to learn it for myself.

Thanks heaps,

- Ben

rocknbil

3:33 am on Sep 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$line =~ s/\(\d+\)/<br>/;

That should do it. Or if you think there might be spaces,

$line =~ s/\(\s*\d+\s*\)/<br>/;

If the data is all on one line and you mean a newline,

$line =~ s/\(\s*\d+\s*\)/\n/g;

Bennie

3:37 am on Sep 15, 2006 (gmt 0)

10+ Year Member



rock--in--bill!

Thanks mate, awesome

Muchos gracias

;-P