1

I need regular expression that will retrieve strings between two pairs of {{ }}, non gridy, ignoring few special characters. For example :

The text: {{Lorem ((ipsum dolor [[sit amet]], consectetur)) adipiscing}}{{elit. ((Proin eget [[felis sit]] amet)) diam}}

Target: Will Match the following 2 matches:

  1. Lorem ipsum dolor sit amet, consectetur adipiscing
  2. elit. Proin eget felis sit amet diam

All the match should be without the partenless, brackets and the braces

user2326167
  • 107
  • 1
  • 6
  • see here http://stackoverflow.com/questions/1454913/regular-expression-to-find-a-string-included-between-two-characters-while-exclu it may help you – samba Apr 27 '13 at 06:55
  • you can match using this pattern "{{[^}]*}}" then replace that few special characters with empty character – Civa Apr 27 '13 at 07:02
  • 1
    This can't be done in a single regex if the same type of braces can be nested indefinitely. What language are you using? – John Dvorak Apr 27 '13 at 07:02
  • I'm using .NET, thanx – user2326167 Apr 27 '13 at 08:44

1 Answers1

1

All the match should be without the partenless, brackets and the braces

Matches are substrings of the original string, you cannot have gaps in them, so what you're asking for is impossible.

You can match for the whole string, then filter out the unneeded characters in your favorite programming language...

{{.*?}}
Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
  • @WesleyBaugh: Dear downvoter, no, you BSing... :/ lookahead/behind is possible for the {{ }} but not for the other braces. And the capabilities of regexes are quite limited, not only by your imagination... – Karoly Horvath Apr 27 '13 at 07:14
  • 2
    lol. I'm waiting for your impossible answer that solves his problem. cheers. – Karoly Horvath Apr 27 '13 at 07:16