grep - Match code of concatenated strings with regex -
i need regex matches code fragments like:
'lo'.'re'.'m'.' ipsum'.' dol'.'or'
i've no idea how start. how if know final string lorem ipsum dolor don't know positions or amount of '.'?
i'm trying find string in source files grep on command line. in code can example like.
$random = 'lo'.'re'.'m'.' ipsum'.' dol'.'or';
you can use tr:
s="'lo'.'re'.'m'.' ipsum'.' dol'.'or'" echo "$s" | tr -d "[.']" lorem ipsum dolor to validate grep:
echo "$s" | tr -d "[.']" | grep -q 'lorem ipsum dolor' echo $? 0
Comments
Post a Comment