Another Table Regex Question

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
GeoBear
Forum Newbie
Posts: 12
Joined: Tue May 12, 2009 4:31 pm

Another Table Regex Question

Post by GeoBear »

Can anyone tell me what kind of regex script I could use to?...

1. Delete every table row that includes the word billion in at least one table cell

2. Delete every row that does NOT include the word billion in at least one table cell

Thanks.
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Another Table Regex Question

Post by prometheuzz »

GeoBear wrote:Can anyone tell me what kind of regex script I could use to?...

1. Delete every table row that includes the word billion in at least one table cell

2. Delete every row that does NOT include the word billion in at least one table cell

Thanks.
Have you tried some things yourself already? If so, could you post it here and explain how/when they failed?
GeoBear
Forum Newbie
Posts: 12
Joined: Tue May 12, 2009 4:31 pm

Re: Another Table Regex Question

Post by GeoBear »

I wouldn't even have a clue where to begin. I'm new to regex. I downloaded a software program called RegExhibit and figured out a really simple script that deletes everything between two elements. But deleting table rows that contain particular words is way over my head.

I tried searching your forums for solutions, but the search function doesn't seem to work properly.
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Another Table Regex Question

Post by prometheuzz »

GeoBear wrote:I wouldn't even have a clue where to begin. I'm new to regex. I downloaded a software program called RegExhibit and figured out a really simple script that deletes everything between two elements. But deleting table rows that contain particular words is way over my head.

I tried searching your forums for solutions, but the search function doesn't seem to work properly.
The first thing is to describe exactly (on paper preferably) how you would do it by "hand". So how does a table row with the a certain value in it differ from a table row that does not have such a value. You might say: "well, one does and one doesn't", but that is not something regex "understands". You'll have to describe it very precisely.
One hint I'll give you is that you need positive look ahead for this. But to be honest, if you're really new to regex, I highly recommend doing some tutorials before plunging in it and trying to do these more advanced things: IMO, that is not the proper way to learn regex (or any other new thing).

By far the best online resource for regex is this site: http://www.regular-expressions.info/ (there's also a "look-around" tutorial)

When you have tried something but get stuck, I'm more than happy to give you a hand, but I'd like you to try first.

Good luck.
GeoBear
Forum Newbie
Posts: 12
Joined: Tue May 12, 2009 4:31 pm

Re: Another Table Regex Question

Post by GeoBear »

OK, I'll check out that website. Thanks for the tip about lookahead.
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Another Table Regex Question

Post by prometheuzz »

GeoBear wrote:OK, I'll check out that website. Thanks for the tip about lookahead.
You're welcome.
Post Reply