Could anybody help me make a proper regular expression from a bunch of text in Ruby. I tried a lot but I don’t know how to handle variable length titles.
The string will be of format <sometext>title:"<actual_title>"<sometext>. I want to extract actual_title from this string.
I tried /title:"."/ but it doesnt find any matches as it expects a closing quotation after one variable from opening quotation. I couldn’t figure how to make it check for variable length of string. Any help is appreciated. Thanks.
.matches any single character. Putting+after a character will match one or more of those characters. So.+will match one or more characters of any sort. Also, you should put a question mark after it so that it matches the first closing-quotation mark it comes across. So:The parentheses are necessary if you want to extract the title text that it matched out of there.