1

In C#, I want to use a regular expression to match words within [[XXX]].

ex;

Vennligst betal følgende faktura: Fakturanr: [[INVOICENO]], Beløp: [[AMOUNT]], Forfall: [[DUEDATE]], KID: [[KID]] til konto: [[GYMACCOUNT]]. Mvh Aktiv365

Alexander
  • 1,969
  • 19
  • 29
  • did you actually try to look it up? – Alexander Nov 16 '15 at 05:19
  • Welcome to SO. Your question sort of reads as a set of requirements. Any code to show? What research have you done? These things will help us help you. Good luck! _[How do I ask a good question?](http://stackoverflow.com/help/how-to-ask)_ –  Nov 16 '15 at 05:45

4 Answers4

2

You can use lookarounds to match the word inside square brackets.

(?<=\[\[)\w+(?=]])
  • \w+ one or more word characters
  • (?<=\[\[) if preceded by [[
  • (?=]]) if followed by ]]

See demo at regexstorm

bobble bubble
  • 16,888
  • 3
  • 27
  • 46
0

try

Use escape character in regex :

 \[\[xxx\]\] in regex
Vanarajan
  • 973
  • 1
  • 10
  • 35
0

You can try the https://regex101.com/

and May be this expression do

\[\[.*\]\]
Ravi Kumar Mistry
  • 1,063
  • 1
  • 13
  • 24
0

You can use this pattern.

Regex r = new Regex(@"\[\[.+?]]");

var matches = r.Matches(input);
M.kazem Akhgary
  • 18,645
  • 8
  • 57
  • 118