0

I am using TextPad 6 find and replace feature using regular expressions.

In the document I need to insert a tab in between every instance where a lowercase letter is followed by an uppercase letter that has no space between them.

But I cannot find the right regex combination to make this simple task work.

Example:

I want to find:

fooBar

replace with

foo [tab] Bar

This will result being a delimited file.

I have used

FIND:[a-z][A-Z] 
REPLACE: &\t 
RESULT: fooB    ar

OR

FIND:[a-z][A-Z] 
REPLACE:\t&
RESULT: fo  oBar

OR

FIND:[a-z][A-Z] 
REPLACE:&\t&
RESULT: fo  oBar

Any ideas?

raina77ow
  • 103,633
  • 15
  • 192
  • 229
  • Perhaps use parentheses? I don't use textpad so I don't know how it's regex works but parentheses help in notepad++, which is what u use. – Jhecht Sep 08 '14 at 20:50
  • If TextPad allows look-arounds, try: `(?<=[a-z])(?=[A-Z])` and replace with `\t`. – OnlineCop Sep 08 '14 at 23:16
  • TextPad does not recognize (?<=[a-z])(?=[A-Z]) I tried it with posix enabled and not enabled. – user2683415 Sep 13 '14 at 01:58

2 Answers2

0

Use capturing groups:

FIND:([a-z])([A-Z])
REPLACE:\1\t\2
raina77ow
  • 103,633
  • 15
  • 192
  • 229
  • This find replace with posix enabled returns Find fooBar and replaces with f oo Ba r – user2683415 Sep 13 '14 at 02:04
  • @user2683415 the solution raina77ow gave works, but you just need to check the Match Case checkbox in the Replace dialog. – Kennah Nov 15 '14 at 04:43
0

Like raina77ow said you need to capture the regex matched groups. This can be done by adding parenthesis.

I think this should do it.

Find:([a-z]+)([A-Za-z]+)
Replace: \1\t\2
ciphercodes
  • 101
  • 2