Inserting a space between letters strung together

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
ciaolorenzo
Posts: 4
Joined: Mon Jul 09, 2007 11:50 pm
Location: Berkeley, CA

Inserting a space between letters strung together

Post by ciaolorenzo »

Hi,
My data looks like this

EarlMarchLookedonHisDyingChild, The.rtf

I'd like to be able to recognize that the letter preceding a capital is the end of a word, so that the data will look like this


Earl March Lookedon His Dying Child, The.rtf


I know that during a first pass I won't be able to break apart "Lookedon". That's okay for now.

Thanks
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Search for: ([[:lower:]])([[:upper:]])
Replace with: \1 \2


Checkmark in Regular Expressions
Checkmark in Match Case

Note the space between \1 and \2
Hope this was helpful.............good luck,
Bob
ciaolorenzo
Posts: 4
Joined: Mon Jul 09, 2007 11:50 pm
Location: Berkeley, CA

Post by ciaolorenzo »

That did it !
Thanks a bunch
JBNY
Posts: 7
Joined: Wed Mar 25, 2009 7:24 pm

Post by JBNY »

I have been using this, but I am stumped on how to get it NOT to pick up words like

McArthur
MacDaddy

Basically not process anything that starts with Mc or Mac

I tried
[^Mc]([[:lower:]])([[:upper:]])

But that seems to not work. Any suggestions?

Thanks
-Joe
-Joe
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

[^Mc] matches any single character that isn't an M or a c (or a newline).

I don't believe you can do what you want in one step with TextPad's weak regex engine.

But you can allow the prefixes to be separated, and then put them back together with
Find what: (Ma?c) ([[:upper:]])
Replace with: \1\2
JBNY
Posts: 7
Joined: Wed Mar 25, 2009 7:24 pm

Post by JBNY »

Thanks, I'll try that. I have acces to other regex products. Is this something I could do with regex in general? If so, do you know what the expression might be.

Thanks
-Joe
-Joe
Post Reply