MATLAB: Extract the number within the bracket number within the bracket I have string a = 'a_b_c_d(1.0)' I need to extract the number within the bracket. my answer shoud be b = '1.0' how can i do this using regular expression or other method? Thank you Best Answer Any number of regular expression would do 'extract whatever is between two brackets:str = 'a_b_c_d(1.0)';regexp(str, '(?<=\()[^)]*(?=\))', 'match', 'once')is one possibility. Thislooks ahead for an opening bracket.matches any number of characters as long as they're not a closing bracketlooks behind for a closing bracket. Related SolutionsMATLAB: How can I extract special contents of a text regexp(yourstring, '(?<=\()[^)]+', 'match')should do it. It matches any sequence of anything but closing brackets preceded by an opening bracket. Note that the opening bracket has to be escaped as it's a special character in regexes. MATLAB: Matching substrings with regexp subexpressions = regexp(expression, '\([^()]+\)', 'match')will match any sequence with two brackets enclosing one or more non-bracket. Related QuestionA simple regex errorRegex: How to match an empty stringRegex questionHow to use REGEXP to match multi-digit valuesHow to parse information between two strings using regular expressionsExtracting consecutive digits using regexpWhat is the use of /begin…../end in regex
Best Answer