Emin Hasanov
Emin Hasanov

Reputation: 1362

Notepad++ regex get 2nd group

I have a tex with 32k lines like this example

A01.2 Some Text
A01.3 some Text
A01.4 3Some Text
A02.0 [some text]
B02.1 Text .05 example

I need to replace white spaces with ';' symbol.

I tried (\S{3}\.\d)(\s) but notepad++ highlights/gets both groupsB02.1 with whitespace.

1st question: how do i disable 1st group, or take only 2nd 2nd question: is there another expression do find only this white space?

Here is the real example:

Upvotes: 3

Views: 1130

Answers (3)

albciff
albciff

Reputation: 18507

If you want to replace the whitespace by ;, so this B02.1 will be B02.1; using notepad++; since you're capturing the groups then use $ notation in the replace expression.

Find: (\S{3}\.\d)(\s) Replace: $1;

$1 is for the first captured group.

Hope it helps,

enter image description here

Upvotes: 2

Andrea Salicetti
Andrea Salicetti

Reputation: 2483

  1. You disable the first group simply not grouping it:

    \S{3}\.\d(\s)
    

Otherwise, the look-behind may suite your case:

(?<=\S{3}\.\d)(\s)

Upvotes: 1

ndnenkov
ndnenkov

Reputation: 36100

Use a lookbehind so B02.1 won't get matched:

(?<=\S{3}\.\d)(\s)

Upvotes: 0

Related Questions