sirkus
sirkus

Reputation: 11

How do I remove underscores from the first word of everyline?

I need to remove _ from the first word of every line of the following:

Hd_pin = row["HD_PIN"];
Hd_vol = row["HD_VOL"];
Hd_town = row["HD_TOWN"];
Hd_pri_lnd = row["HD_PRI_LND"];

Upvotes: 0

Views: 446

Answers (2)

Eduardo Escobar
Eduardo Escobar

Reputation: 3389

Look for

^_*?([^_=]+)_?

Replace by:

$1

You may need to run the operation several times until Notepad++ says "Can't find the text..."

By the way, don't forget to select "Regular Expression" in the Search Mode section.

Edit: added fix, just in case the first word begins with _

Upvotes: 1

user557597
user557597

Reputation:

This works in notepad++.

Globally,
find: (?m)(?:(?!^)\G|^\h*)[^\W_]*\K_
replace with nothing

https://regex101.com/r/sQVNZm/1

Readable

 (?m)                 # Multi-line mode
 (?:
      (?! ^ )              # Not BOL
      \G                   # Start where last match left off
   |                     # or,
      ^ \h*                # BOL, optional horizontal wsp
 )
 [^\W_]*              # Optional words, not underscore
 \K                   # Ignore up to here
 _                    # Until the next underscore

Upvotes: 0

Related Questions