I need to find a line from a file and replace it:
Suppose this the content in the file: ‘547714,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0’
Based on 547714 i need to select and replace the complete line
i am using this regexp: '/^.*547714.*$/';
But its not selecting anything.
The regex looks OK. However, you need to tell the regex engine to allow the
^and$anchors to match the start and end of each line (and not the entire input string). That’s what the/mmodifier is for. Also, word boundaries (\b) are a good idea here to avoid substring matches.So I’d suggest
This will match an entire line containing
345345(but it won’t match a line like1,53453456,4,5,0).