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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -