Hi need help in using regexp for condition matching.
ex.my file has the following content
{hello.program=’function’`;
bye.program=’script’; }
I am trying to use regexp to match the string that has .program='function' in them:
pattern = '[.program]+\=(function)'
also tried pattern='[^\n]*(.hello=function)[^\n]*';
pattern_match = regexp(myfilename,pattern , 'match')
but this returns me pattern_match={} while i expect the result to be hello.program=’function’`;
If
'function'comes with string-markers, you need to include these in the match. Also, you need to escape the dot (otherwise, it’s considered “any character”).[.program]+looks for one or several letters contained in the square brackets – but you can just look forprograminstead. Also, you don’t need to escape the=-sign (which is probably what messed up the match).EDIT
In response to the comment
Here’s how you find the matching lines with regexp