# Use regular expression in systemverilog to remove "anything start with some predefined letter "

**URL:** <https://verificationacademy.com/forums/t/use-regular-expression-in-systemverilog-to-remove-anything-start-with-some-predefined-letter/37660>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, UVM, queues-systemverilog, regular-expressions, systemverilog-Strings\
**Created:** [June 2, 2020, 1:25pm UTC](https://verificationacademy.com/forums/t/use-regular-expression-in-systemverilog-to-remove-anything-start-with-some-predefined-letter/37660 "2020-06-02T13:25:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlokMandal](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/b5a626/32.png) [@AlokMandal](https://verificationacademy.com/forums/u/AlokMandal)\
**Post date:** [June 2, 2020, 1:25pm UTC](https://verificationacademy.com/forums/t/use-regular-expression-in-systemverilog-to-remove-anything-start-with-some-predefined-letter/37660/1 "2020-06-02T13:25:51Z")

</div>

Hi everyone,  
i have one queue of string, i want to remove "anything which start with UVM ". for example UVM\_VERBOSITY,UVM\_TESTNAME etc.  
i know how to do it using perl because it supports regular expression very well. but in Systemverilog regex does not support that much (at least in vcs, ignore it).

```verilog
module tb;
  initial begin
    string test_queue[$]={"xyz","abc","UVM_VERBOSITY","UVM_TESTNAMES","systemverilog"};
    $display(" Q : %p",test_queue);
  end
endmodule

Output : 
Q : '{"xyz", "abc", "UVM_VERBOSITY", "UVM_TESTNAMES", "systemverilog"}

```

```verilog
 i want Q : '{"xyz", "abc", "systemverilog"}

```

can you help me how to procced , to remove them.

Thanks,  
Alok

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [June 2, 2020, 4:52pm UTC](https://verificationacademy.com/forums/t/use-regular-expression-in-systemverilog-to-remove-anything-start-with-some-predefined-letter/37660/2 "2020-06-02T16:52:40Z")

</div>

_In reply to [Alok\_Mandal](https://verificationacademy.com/forums/t/use-regular-expression-in-systemverilog-to-remove-anything-start-with-some-predefined-letter/37660):_

You don’t need regular expressions for simple matches like this

```verilog
module tb;
  string test_queue[$]={"xyz","abc","UVM_VERBOSITY","UVM_TESTNAMES","systemverilog"};

  initial begin
    test_queue = test_queue.find(s) with ("UVM" != s.substr(0,2));
    $display(" Q : %p",test_queue);
  end
endmodule

```

If you really need regular expressions, the UVM provides uvm\_re\_match(re,str).
