-1

I got the following text:

Code = ABCD123 | Points = 30
Code = ABCD333 | Points = 44

At the end, I want to removing anything except the Code, output:

ABCD123
ABCD333

I actually tried it with Code = | P.+

But I don't know how to get "|" removed. Currently, I have just ÀBCD333 | left as an example. I'm struggling there.

dnz
  • 23
  • 4

2 Answers2

0

Assuming the code only consists of word characters, you may use the following:

^Code = (\w+).+$

..and replace with:

\1

Demo.

If the code can be anything, you may use something like this instead:

^Code = (.+?)[ ]\|.+$
ICloneable
  • 613
  • 3
  • 17
-1
  • Ctrl+H
  • Find what: ^Code = (\w+).+
  • Replace with: $1
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

^           # beginning of line
  Code =    # literally
  (\w+)     # group 1, 1 or more word character
  .+        # 1 or more any character but newline

Replacement:

$1          # content of group 1

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

Toto
  • 89,455
  • 62
  • 89
  • 125