Search code examples
regexjmeterresponse

Jmeter regular expression to exclude string/word


Is there's a way to extract and exclude the entire line that has "ls Cannot access" Your response is highly appreciated. Thank you so much

Sample Response:

10.179.10.12 ls: cannot access /home/bushido/components/pkg-build-ng/version/2-328/_MANIFEST.linux: No such file or directory 10.179.10.13 ls: cannot access /home/bushido/components/pkg-build-ng/version/2-328/_MANIFEST.linux: No such file or directory 10.179.10.14 /home/bushido/components/pkg-build-ng/version/2-328/_MANIFEST.linux

enter image description here

Expected Result:

10.179.10.14 /home/bushido/components/pkg-build-ng/version/2-328/_MANIFEST.linux

enter image description here

Note: The IP address are dynamic


Solution

  • You can use

    (?m)^(?!.*ls: cannot access)(.+)
    

    Details:

    • (?m) - multiline inline flag to make ^ match start of a line, not just start of a string
    • ^ - start of a line
    • (?!.*ls: cannot access) - a negative lookahead that fails the match if there are any zero or more chars other than line break chars, as many as possible, and then ls: cannot access string
    • (.+) - Group 1: one or more chars other than line break chars, as many as possible (the whole line).