0

Problem 1

Lets say I have this word realPersonId and want to find in text and replace it with word without Id suffix. First letter needs to be capital. I can't get that capital.

Sample text: realPersonId
Find expression: (\s+)(.*)Id
Replace expression: \1\2
Result: realPerson
Wanted result: RealPerson

Problem 2

In this problem I don't have any solution, all I want with sample text is to replace it with concatenated text, size of maximum 26 letters.

Sample text: table="EXAMPLE_INFORMATION_123456789"
Find expression: table="(.*)"
Replace expression: \1
Result: EXAMPLE_INFORMATION_123456789
Wanted result: EXAMPLE_INFORMATION_123456

Thanks.

shx
  • 1,068
  • 1
  • 14
  • 30

1 Answers1

1

Problem 1 solution:

Find What: (\w+)Id
Replace With: \u\1

Note: The following modifiers may be used to change the case of the backreference during the replacement:

\l     # first character to lower case
\u     # first character to upper case
\L     # start of lower case conversion
\U     # start of upper case conversion
\E     # end lower/upper case conversion

Problem 2 solution:

Find What: table="(.{26})[^"]+"
Replace With: \1

This captures exactly 26 characters and discards the rest using a negated class outside the capturing group, if you want a minimum you could use .{min,26}, the dot . will match any character except newline.

hwnd
  • 69,796
  • 4
  • 95
  • 132
  • Thanks hwnd. Solution 1 works perfectly, Solution 2 is good but I'm having some problems. It want find me names shorter than 26 characters, like this `table="EXAMPLE_INFORMATION"`. I want to do something like this: if it's shorter than 26 characters live it as is, if longer cut it. I want `"` to be a break. – shx Aug 25 '14 at 08:30
  • 1
    Try `table="(.{1,26}).*?"` – hwnd Aug 25 '14 at 11:51
  • That's it :) Thank you very much. Do you have any books, articles or some tutorial on the web to recommend? – shx Aug 25 '14 at 12:09