Page 1 of 1

Search and Replace with Regular Expressions

Posted: Mon Sep 08, 2003 9:09 am
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 ??

Posted: Mon Sep 08, 2003 12:24 pm
by Ed
Search for
TextPad
replace with
Text\nPad

with "regular expression" checked

Posted: Mon Sep 08, 2003 12:31 pm
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 ??
:?:

Posted: Mon Sep 08, 2003 1:41 pm
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

Posted: Mon Sep 08, 2003 2:09 pm
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

Posted: Mon Sep 08, 2003 2:20 pm
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

Posted: Mon Sep 08, 2003 2:23 pm
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

Posted: Mon Sep 08, 2003 2:35 pm
by Beam4711
:)
Great !! It works. Thanks for any help !!

Posted: Mon Sep 08, 2003 2:49 pm
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.