-1

I have some text with several special charakters in it and i want to get the text between the special charakters. I am gogin fin with something like this:

=== TestText === 

This works with the regex:

/(?:^|\s)=== (.*?) ===(?:\s|$)/g

There i get TestText. But now my Problem is when i want to get some text between two square brackets.

[[This is a text]] 

with the regex : /(?:^|\s)\[\[ (.*?) \]\](?:\s|$)/g i don't get any result. can you help me ?

Thank you in Advance!

Toopf
  • 25
  • 1
    Remember, spaces in the pattern match spaces in the input string. Your pattern *would* have matched the input of `[[ This is a text ]]` – freefaller Aug 03 '15 at 11:23
  • oh thank you .. i should take a break -.- can't see the simplest things. no i'ts working – Toopf Aug 03 '15 at 11:31

1 Answers1

2

You can use this regex:

\[+(.*?)\]+

and grab captured group #1. This matches 1+ of [s followed by 0 or more of any characters followed by 1+ of ] characters.

RegEx Demo

anubhava
  • 761,203
  • 64
  • 569
  • 643