Page 1 of 1

How to find a specific number of occurrences of a character

Posted: Tue Jun 16, 2009 3:16 pm
by jimbo2112
Hi All,

Searched to no avail on this one. As I understand, the reg ex for catching one occurrence of a character you would search with {1}. TextPad does not like this. My aim is to find things like this:

What a BigProblem this is

Using

\([a-z]{1}\)\([A-Z]{1}\)

and replace with

\1 \2

so, the result would be:

What a Big Problem this is

Any suggestions on how to restrict the search length to 1 character?

PS I have switched on case sensitivety!

Many thanks

Jimbo

Posted: Tue Jun 16, 2009 4:41 pm
by jimbo2112
Panic over. I had the correct reg-ex in the first place, but for some reason the POSIX option was switched off in preferences. In case anyone was wondering, the actual search string with POSIX in place would not need the `\` before the `(`:

([a-z]{1})([A-Z]{1})

Thanks anyways!

Posted: Tue Jun 16, 2009 4:53 pm
by ben_josephs
You were mixing Posix and non-Posix syntax.

Anyway, x{1} is equivalent to x , so the braces are unnecessary.

So this is all you need:
Find what: ([a-z])([A-Z])
Replace with: \1 \2

[X] Regular expression

Posted: Tue Jun 16, 2009 5:11 pm
by jimbo2112
Indeed I was in the first post.

So in POSIX, the default match value is 1?

Posted: Tue Jun 16, 2009 5:47 pm
by ben_josephs
In every style of regex (there are many), x matches a single x.

Posted: Tue Jun 16, 2009 5:48 pm
by jimbo2112
Cheers Ben, Handy to know.