I have a text like this:
line 1/1/1/2
The text after the line phrase is the parameter of a function, for example when I call extractData('1/1/1/2' , 'The main text')
:
function extractData($line, $text)
{
$pattern = "/line(\s+)$line/";
if(preg_match($pattern, $text)) {
// some code
}
}
How can I escape the slash character in the pattern?
In other words, how should I write the pattern? ($pattern = "/line(\s+)$line/";
)