c# - Get text inside a tag with Regex -
i trying text inside tag, call keyword. example [@sometext].
i not able text. trying use this, reading html , define inside html keywords sometext explained before, need sometext , not [@sometext] using regex. how can ?
the current regex using one: \[@\w+\].
that regex [@sometext] , not sometext. tried everything.
thank !
edit
the solution use (?<=\[@)\w+(?=\]) because using matches not match method.
combine match content positive lookbehind [@ , positive lookahead closing [, (?<=\[@)\w+(?=\]). explanation (courtesy of regexbuddy):
assert regex below can matched, match ending @ position (positive lookbehind)
(?<=\[@)match character "[" literally
\[match character "@" literally
@match single character "word character" (letters, digits, etc.)
\w+- between 1 , unlimited times, many times possible, giving needed (greedy)
assert regex below can matched, starting @ position (positive lookahead)
(?=\])- match character "]" literally «]»
Comments
Post a Comment