-1

I have a text looking like this

name_123 name 2022-6-1 abc

I want this

name_123

How can I do that?

phuclv
  • 26,555
  • 15
  • 113
  • 235
Tobi
  • 1
  • 1
  • 1

2 Answers2

0
  • Ctrl+H to open the replace dialog
  • Find what: .*
  • Replace with: empty
  • Search mode: regular expression, with . matches newline not checked
  • Replace All

.* means searching for a space ( ) followed by any characters (.*). Regex matches greedily by default so it'll match everything from the first space until the end of line

See also

phuclv
  • 26,555
  • 15
  • 113
  • 235
0

You can also target the first word instead with: ^([^\s]*)\s.*$
and replace with: \1.

Dominique
  • 1,993
  • 9
  • 30
  • 65