0

I have below string

Dim strTemplate as string = 
"<table>
  <tr>
       <td>Name</td>
       <td>Address</td>
       <td>City</td>   
  </tr>
  <tr>
       <td>[%Name%]</td>
       <td>[%Address%]</td>
       <td>[%City%]</td>   
  </tr>
</table>"

Dim strSplits = New List(Of String)(Regex.Split(strval, "REGEXRequired"))

Now i want to write regex with split above string and give only pattern string [%...%].

i.e. want [%Name%], [%Address%], [%City%] values in strSplits list.

any suggestion or help will be appreciated .

2 Answers 2

3

Why would you use Split() for that?

Dim strSplits = New List(Of String)(Regex.Matches(strval, "\[%.*?%\]"))

is much easier, isn't it?

Sign up to request clarification or add additional context in comments.

3 Comments

how can take distinct values ?
@PrakashPatani: What do you mean?
I mean matching value array contain distinct values. I had managed to do that..thanks for your help
1

this will get you going

/(\[%.*?%\])/g

demo here : http://regex101.com/r/kV2rK4

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.