如何使用regEx忽略单词替换?

时间:2016-09-02 12:14:51

标签: regex

<select class="form-control" name="work_status">
                          <option value="">Working With</option>
                          <option value="Private Company">Private Company</option>
                          <option value="Government/ Public sector">Government/Public Sector</option>
                           <option value="Government/ Public sector">Defense/Civil Services</option>
                             <option value="Government/ Public sector">Business/Self Employed</option>
                           <option value="Government/ Public sector">Not Working</option>
</select>

我要删除所有<option value="Ignore this">。这意味着我想将<option value="">替换为&#34;&#34;和<option value="Private Company">与&#34;&#34;。即我想忽略value属性中的单词。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

您必须指定一种语言,但对于正则表达式部分,您可以使用此语言:value="(.+)"

Regex101

无论如何你不需要正则表达式。你可以用javascript做到这一点。假设您使用jQuery:

$('.form-control option').each(function(){
    $(this).attr('value',"");
});