FAQ Database Discussion Community


Regexp capture unlimited groups

regex,capturing-group
I need a little help here. So I have string: {block name="something" param1="param" param2="param"} it can be: {block name="something"} or {block name="something" param1="value" sm="value" ng="value" um="param" .. and so on}. What I need is to capture all possible params. What I could figure out so far is {(?<type>[\w]+) ((?<param>[\w]+)="(?<value>[\w]+)"), but...

Capture a substring of a matched group

regex,lookahead,capturing-group
Scanario I have to grab a substring from a composed string. Match condition: string starts with 'section1:' captured string may be a blank separated or a dash separated list of alphanumerical values if the captured string ends with a specific suffix ('-xx'), exclude the suffix from the captured string. Examples...

Regex optional capturing group?

regex,optional,capturing-group
After hours of searching I decided to ask this question. Why this regular expression: ^(dog).+?(cat)? doesn't work as I think it should work (capture the first dog and cat if there is any)? What am I missing here? dog, cat dog, dog, cat dog, dog, dog ...

Java regex: extract function names

java,regex,capturing-group
I'm trying to extract a list of function names from a formula, but my regex is not working. Given ( aaa(111) + bbb(222) ) / ccc ( 333 ) I need to obtain an array of strings containing aaa, bbb and ccc. Instead, I'm getting aaa(, bbb( and ccc (....