I have a test file with number values as below:

32405494
32405495
32405496
32407498

Using Notepad++, what I am trying to achieve here is to search the first 4 digits using regular expression and replace the whole number with G3E_STYLERULE_SEQ.NEXTVAL

I am able to find these values using 3240*. My question is, how do I replace the whole number with G3E_STYLERULE_SEQ.NEXTVAL?

When I am click the Replace All button, I get the following output:

G3E_STYLERULE_SEQ.NEXTVAL5494
G3E_STYLERULE_SEQ.NEXTVAL5495
G3E_STYLERULE_SEQ.NEXTVAL5496
G3E_STYLERULE_SEQ.NEXTVAL7498

However, I am expecting the following:

G3E_STYLERULE_SEQ.NEXTVAL
G3E_STYLERULE_SEQ.NEXTVAL
G3E_STYLERULE_SEQ.NEXTVAL
G3E_STYLERULE_SEQ.NEXTVAL

Any ideas to achieve this? Is it even possible through Notepad++? Are there any other text editors which I can use to achieve this?

有帮助吗?

解决方案

Use something like this:

3240.*

. is the wildcard character in regex and * means that the previous character is to be repeated 0 or more times (your current regex actually matches 324 and then 0 which appears 0 or more times).

3240.* will therefore match 3240 and any other following characters.

You might also want to add a line anchor:

^3240.*

So that you don't replace numbers having 3240 in the middle too.

其他提示

in notepad++, you can use this regex:

^3240\d+

it will match the four digits you're searching at the beginning of your string followed by any digit.

Try this -

Search this - ^3240\d*$
Replace with- G3E_STYLERULE_SEQ.NEXTVAL
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top