How to find variable length words...

General questions about using WildEdit

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
frich96
Posts: 2
Joined: Thu Jan 21, 2010 3:13 pm
Location: New York, United States

How to find variable length words...

Post by frich96 »

Hi,

I'm sure this has been covered somewhere before... but my searches didn't give any useful results.

I am trying to edit a collection of XML documents that have variable length words that I want to replace with the same word;

words are formatted as: "User-#", or...
"User-##", or...
"User-###"

where "#" is an integer number from 0-9.

All words are (planned) to be replaced with "User-2".

Each method I've tried leaves me with a new word that that is made of the replacement word + all the original #'s from the original word.

Can anyone help?

Thanks,
Fred
frich96
Posts: 2
Joined: Thu Jan 21, 2010 3:13 pm
Location: New York, United States

SOLVED - How to find variable length words...

Post by frich96 »

OK.

I think I've found, at least a work around if not the best answer. Due to the fact that my data is fairly homogeneous, I can submit the following FINDs in this order...

1. Find "User-[0-9][0-9][0-9]" --> execute
2. Find "User-[0-9][0-9]" --> execute
3. Find "User-[0-9]" --> execute

Of course, with runs 2 and 3, I'm actually re-editing previous edits, but it ends with the intended replaced text in all files.

*Still interested if there's a better way (single pass?) to do this.*

Thanks,
Fred
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

User-[0-9]+ for any non-zero number of digits
or
User-[0-9]{1,3} for 1, 2 or 3 digits

In WildEdit (but not in TextPad) you can use \d for [0-9].
Post Reply