如何从每行的第一个单词中删除下划线?

时间:2018-07-09 18:10:27

标签: regex notepad++

我需要从以下各行的第一个单词中删除_:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="row">
  <div class="twelve columns">
    <ul class="block-grid four-up mobile-two-up productlist">

      <li class="item">
        <div class="itemWrapper pOverlay">
          <div class="pImageContainer">
            <a class="plink image" href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166">
              <div class="pLabel comingsoon"><span>Coming soon</span></div>
              <div data-picture data-alt="Jordan - AIR JORDAN 3 RETRO SE Q54" jail="true">

                <div data-src="/files/image/id/66689/fixed/1/w/150/h/150/n/jordan-air-jordan-3-retro-se-q54-at9195-001-1.jpg"></div>
                <div data-src="/files/image/id/66689/fixed/1/w/400/h/400/n/jordan-air-jordan-3-retro-se-q54-at9195-001-1.jpg" data-media="(min-width: 400px)"></div>
                <div data-src="/files/image/id/66689/fixed/1/w/300/h/300/n/jordan-air-jordan-3-retro-se-q54-at9195-001-1.jpg" data-media="(min-width: 800px)"></div>

                <noscript>
                          <img src="/files/image/id/66689/fixed/1/w/400/h/400/n/jordan-air-jordan-3-retro-se-q54-at9195-001-1.jpg" alt="Jordan - AIR JORDAN 3 RETRO SE Q54">
                        </noscript>
              </div>
              <img src="/files/image/id/white/fixed/1/w/400/h/400/n/white.jpg" id="" class="" alt="Jordan - AIR JORDAN 3 RETRO SE Q54" />
              <div class="pImageLoader" style="display:none;">
                <div class="spinner small"></div>
              </div>
            </a>
          </div>
          <div class="pText">
            <a class="pName" title="Jordan - AIR JORDAN 3 RETRO SE Q54" href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166">
              <span class="producername">Jordan</span>
              <span class="productname">AIR JORDAN 3 RETRO SE Q54</span>
            </a>
            <span class="price">
                      €179.99                    </span>
            <div class="pAdditions">
              <hr />
              <div class="variantSelectorGroup">
                <span class="reminderHeadline">Notify me</span>
                <ul class="variantSelector">
                  <li class="variantTitle">Size</li>
                  <li><a class="variantSelectorSelect active" displaygroup="EU">EU</a></li>
                  <li><a class="variantSelectorSelect " displaygroup="US">US</a></li>
                </ul>
                <ul class="availableVariants">
                  <li class="soldout" title="Notify me">
                    <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92167" EU='40' US='7'>40</a>
                    <li class="soldout" title="Notify me">
                      <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92168" EU='40,5' US='7,5'>40,5</a>
                      <li class="soldout" title="Notify me">
                        <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92169" EU='41' US='8'>41</a>
                        <li class="soldout" title="Notify me">
                          <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92170" EU='42' US='8,5'>42</a>
                          <li class="soldout" title="Notify me">
                            <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92171" EU='42,5' US='9'>42,5</a>
                            <li class="soldout" title="Notify me">
                              <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92172" EU='43' US='9,5'>43</a>
                              <li class="soldout" title="Notify me">
                                <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92173" EU='44' US='10'>44</a>
                                <li class="soldout" title="Notify me">
                                  <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92174" EU='44,5' US='10,5'>44,5</a>
                                  <li class="soldout" title="Notify me">
                                    <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92175" EU='45' US='11'>45</a>
                                    <li class="soldout" title="Notify me">
                                      <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92176" EU='45,5' US='11,5'>45,5</a>
                                      <li class="soldout" title="Notify me">
                                        <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92177" EU='46' US='12'>46</a>
                                        <li class="soldout" title="Notify me">
                                          <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92178" EU='47' US='12,5'>47</a>
                                          <li class="soldout" title="Notify me">
                                            <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92179" DEFAULT='US 13'></a>
                                            <li class="soldout" title="Notify me">
                                              <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92180" EU='48,5' US='14'>48,5</a>
                                              <li class="soldout" title="Notify me">
                                                <a href="/en/p/jordan-air-jordan-3-retro-se-q54-at9195-001-92166-92181" EU='49,5' US='15'>49,5</a>
                </ul>
              </div>
              <div class="shippingInfo">
                Free shipping to United Kingdom </div>
            </div>

          </div>
        </div>
        </li>
        <li class="item">
          <div class="itemWrapper pOverlay">
            <div class="pImageContainer">
              <a class="plink image" href="/en/p/nike-air-max-1-ar1249-001-71499">
                <div data-picture data-alt="Nike - AIR MAX 1" jail="true">

                  <div data-src="/files/image/id/66793/fixed/1/w/150/h/150/n/nike-air-max-1-ar1249-001-1.jpg"></div>
                  <div data-src="/files/image/id/66793/fixed/1/w/400/h/400/n/nike-air-max-1-ar1249-001-1.jpg" data-media="(min-width: 400px)"></div>
                  <div data-src="/files/image/id/66793/fixed/1/w/300/h/300/n/nike-air-max-1-ar1249-001-1.jpg" data-media="(min-width: 800px)"></div>

                  <noscript>
                          <img src="/files/image/id/66793/fixed/1/w/400/h/400/n/nike-air-max-1-ar1249-001-1.jpg" alt="Nike - AIR MAX 1">
                        </noscript>
                </div>
                <img src="/files/image/id/white/fixed/1/w/400/h/400/n/white.jpg" id="" class="" alt="Nike - AIR MAX 1" />
                <div class="pImageLoader" style="display:none;">
                  <div class="spinner small"></div>
                </div>
              </a>
            </div>
            <div class="pText">
              <a class="pName" title="Nike - AIR MAX 1" href="/en/p/nike-air-max-1-ar1249-001-71499">
                <span class="producername">Nike</span>
                <span class="productname">AIR MAX 1</span>
              </a>
              <span class="price">
                      €149.99                    </span>
              <div class="pAdditions">
                <hr />
                <div class="variantSelectorGroup">
                  <ul class="variantSelector">
                    <li class="variantTitle">Size</li>
                    <li><a class="variantSelectorSelect active" displaygroup="EU">EU</a></li>
                    <li><a class="variantSelectorSelect " displaygroup="US">US</a></li>
                  </ul>
                  <ul class="availableVariants">
                    <li title="">
                      <a href="/en/p/nike-air-max-1-ar1249-001-71499-71500" EU='41' US='8'>41</a>
                      <li title="">
                        <a href="/en/p/nike-air-max-1-ar1249-001-71499-71501" EU='42' US='8,5'>42</a>
                        <li title="">
                          <a href="/en/p/nike-air-max-1-ar1249-001-71499-71502" EU='42,5' US='9'>42,5</a>
                          <li title="">
                            <a href="/en/p/nike-air-max-1-ar1249-001-71499-71503" EU='43' US='9,5'>43</a>
                            <li title="">
                              <a href="/en/p/nike-air-max-1-ar1249-001-71499-71504" EU='44' US='10'>44</a>
                              <li title="">
                                <a href="/en/p/nike-air-max-1-ar1249-001-71499-71505" EU='44,5' US='10,5'>44,5</a>
                                <li title="">
                                  <a href="/en/p/nike-air-max-1-ar1249-001-71499-71506" EU='45' US='11'>45</a>
                                  <li title="">
                                    <a href="/en/p/nike-air-max-1-ar1249-001-71499-71507" EU='45,5' US='11,5'>45,5</a>
                                    <li title="">
                                      <a href="/en/p/nike-air-max-1-ar1249-001-71499-71508" EU='46' US='12'>46</a>
                  </ul>
                </div>
                <div class="shippingInfo">
                  Free shipping from €170.00 to United Kingdom </div>
              </div>

            </div>
          </div>
          </li>
          <li class="item">
            <div class="itemWrapper pOverlay">
              <div class="pImageContainer">
                <a class="plink image" href="/en/p/nike-air-max-90-premium-se-858954-600-73728">
                  <div data-picture data-alt="Nike - Air Max 90 Premium SE" jail="true">

                    <div data-src="/files/image/id/66790/fixed/1/w/150/h/150/n/nike-air-max-90-premium-se-858954-600-1.jpg"></div>
                    <div data-src="/files/image/id/66790/fixed/1/w/400/h/400/n/nike-air-max-90-premium-se-858954-600-1.jpg" data-media="(min-width: 400px)"></div>
                    <div data-src="/files/image/id/66790/fixed/1/w/300/h/300/n/nike-air-max-90-premium-se-858954-600-1.jpg" data-media="(min-width: 800px)"></div>

                    <noscript>
                          <img src="/files/image/id/66790/fixed/1/w/400/h/400/n/nike-air-max-90-premium-se-858954-600-1.jpg" alt="Nike - Air Max 90 Premium SE">
                        </noscript>
                  </div>
                  <img src="/files/image/id/white/fixed/1/w/400/h/400/n/white.jpg" id="" class="" alt="Nike - Air Max 90 Premium SE" />
                  <div class="pImageLoader" style="display:none;">
                    <div class="spinner small"></div>
                  </div>
                </a>
              </div>
              <div class="pText">
                <a class="pName" title="Nike - Air Max 90 Premium SE" href="/en/p/nike-air-max-90-premium-se-858954-600-73728">
                  <span class="producername">Nike</span>
                  <span class="productname">Air Max 90 Premium SE</span>
                </a>
                <span class="price">
                      €144.99                    </span>
                <div class="pAdditions">
                  <hr />
                  <div class="variantSelectorGroup">
                    <ul class="variantSelector">
                      <li class="variantTitle">Size</li>
                      <li><a class="variantSelectorSelect active" displaygroup="EU">EU</a></li>
                      <li><a class="variantSelectorSelect " displaygroup="US">US</a></li>
                    </ul>
                    <ul class="availableVariants">
                      <li title="">
                        <a href="/en/p/nike-air-max-90-premium-se-858954-600-73728-73729" EU='41' US='8'>41</a>
                        <li title="">
                          <a href="/en/p/nike-air-max-90-premium-se-858954-600-73728-73730" EU='42' US='8,5'>42</a>
                          <li title="">
                            <a href="/en/p/nike-air-max-90-premium-se-858954-600-73728-73731" EU='42,5' US='9'>42,5</a>
                            <li title="">
                              <a href="/en/p/nike-air-max-90-premium-se-858954-600-73728-73732" EU='43' US='9,5'>43</a>
                              <li title="">
                                <a href="/en/p/nike-air-max-90-premium-se-858954-600-73728-73733" EU='44' US='10'>44</a>
                                <li title="">
                                  <a href="/en/p/nike-air-max-90-premium-se-858954-600-73728-73734" EU='44,5' US='10,5'>44,5</a>
                                  <li title="">
                                    <a href="/en/p/nike-air-max-90-premium-se-858954-600-73728-73735" EU='45' US='11'>45</a>
                                    <li class="soldout" title="Notify me">
                                      <a href="/en/p/nike-air-max-90-premium-se-858954-600-73728-73736" EU='45,5' US='11,5'>45,5</a>
                                      <li title="">
                                        <a href="/en/p/nike-air-max-90-premium-se-858954-600-73728-73737" EU='46' US='12'>46</a>
                    </ul>
                  </div>
                  <div class="shippingInfo">
                    Free shipping from €170.00 to United Kingdom </div>
                </div>

              </div>
            </div>
            </li>
    </ul>
  </div>
</div>
<!-- <PRODUCTLIST CATEGORY> END -->

2 个答案:

答案 0 :(得分:1)

寻找

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

替换为:

$1

您可能需要运行几次该操作,直到Notepad ++提示“找不到文本...”

顺便说一句,不要忘记在“搜索模式”部分中选择“正则表达式”。

编辑:添加了修复程序,以防万一第一个单词以_

开头

答案 1 :(得分:0)

这在notepad ++中有效。

在全球范围内,
找到:(?m)(?:(?!^)\G|^\h*)[^\W_]*\K_
一无所有

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

可读

 (?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