3

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:

5
  • I'm confused - what is your desired output? B02.1;Text;.05;example?
    – ʰᵈˑ
    Commented Aug 21, 2015 at 8:03
  • I guess you only need to match the space after A01.2, B02.1.... that are always at the beginning of the line? Commented Aug 21, 2015 at 8:04
  • I think one of the safest is ^[A-Z0-9.]+\K\s+, or ^[A-Z0-9]+\.\d+\K\s+. Commented Aug 21, 2015 at 8:09
  • @eminach: Did you have time to check the posted suggestions? Please let us know. I do not want to post my answer if there is one that is valid and working for you. Commented Aug 21, 2015 at 8:50
  • Thanks all, 1. @albcif post helped, 2 @Andrea's (?<=\S{3}\.\d)(\s) expression works Commented Aug 21, 2015 at 11:24

3 Answers 3

2

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

1
  • @eminach nice to help you :)
    – albciff
    Commented Aug 21, 2015 at 11:34
1
  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)
0
0

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.