Search and Replace with Regular Expressions

General questions about using TextPad

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

Post Reply
Beam4711
Posts: 10
Joined: Mon Sep 08, 2003 9:06 am

Search and Replace with Regular Expressions

Post by Beam4711 »

I want to search a Textfile for all words for example

TextPad

and want to break it like

Text
Pad


I think i can do this with search an replace with Regular Expressions, but how cai i do this exactly ??
Ed
Posts: 103
Joined: Tue Mar 04, 2003 9:09 am
Location: Devon, UK

Post by Ed »

Search for
TextPad
replace with
Text\nPad

with "regular expression" checked
Beam4711
Posts: 10
Joined: Mon Sep 08, 2003 9:06 am

Post by Beam4711 »

Thanks for answer. Your example woks with the word TextPad.

I need to use it with any words in a list of about 300 000 Words.

So I search for [a-z][A-Z] and then tried to replace with [a-z]\n[A-Z], but this doesn’t work ??
:?:
User avatar
webmasta
Posts: 169
Joined: Mon Jul 28, 2003 8:16 pm
Location: Toronto

Post by webmasta »

I need to use it with any words in a list of about 300 000 Words
So you dont know the specific words.
What will identify the words that need breaking?
And where will they break... 3,4,5 or n th letter?
Tough nut to crack...I've been sitting here last 15 mins figuring this may be some kind of joke??

webM
Beam4711
Posts: 10
Joined: Mon Sep 08, 2003 9:06 am

Post by Beam4711 »

Sorry, this is not a joke.

I´ve got a list of words. Some of them are put together like TrainStation, but this should be two different words.

The words will be identified with the combination of Uppercase after Lowercase. This works well with the search for [a-z][A-Z].

For these words I´ll need a break between the Lowercase and the Uppercase. In our Example Textpad finds with regular expressions and the search for [a-z][A-Z] the Word TrainStation, and this word should be broken like

Train
Station


Using [a-z]\n[A-Z] in the field replace, produces

Trai[a-z]
[A-Z]tation
User avatar
webmasta
Posts: 169
Joined: Mon Jul 28, 2003 8:16 pm
Location: Toronto

Post by webmasta »

:lol:
Now we hear the whole story after I had to pull some teeth, hope I didnt destroy ure smile.

Tell ya what, Bob is a genius at this, he'll figure it out when he sees ure post... hold tight... or maybe Ed back to the rescue.

webM
Ed
Posts: 103
Joined: Tue Mar 04, 2003 9:09 am
Location: Devon, UK

Post by Ed »

Reg exp checked
Match case checked
Configure->Preferences->Editor->Use Posix... - Unchecked
Search for
\([a-z]\)\([A-Z]\)
replace with
\1\n\2
Beam4711
Posts: 10
Joined: Mon Sep 08, 2003 9:06 am

Post by Beam4711 »

:)
Great !! It works. Thanks for any help !!
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Thanks Ed.....
So you dont know the specific words.
What will identify the words that need breaking?
And where will they break... 3,4,5 or n th letter?
Tough nut to crack...I've been sitting here last 15 mins figuring this may be some kind of joke??
:!: :!:
Whew...Glad I didn't have to work on that one! Fifteen minutes wouldn't begin to do it justice :D

The final information made it easy........well done.
Post Reply