E
E
Evgeny Fedorov2014-03-06 09:49:07
PHP
Evgeny Fedorov, 2014-03-06 09:49:07

Why is Sublime not friendly with regex?

Sublime will syntactically highlight the parenthesis as an error in this code, why and how to get rid of it?

$new_var= preg_replace(/href="\/uploads/, '123', $var);

1394088341-clip-14kb.jpg?nocache=1
All of the following code is highlighted in one color and is not broken into syntax.
It's impossible to work.
Same thing in java script. At least you can write in it:
var emailFilter = /^[_/a-zA-Z0-9]+([!"#$%&()*+,./:;/]) ;

1394108065-clip-14kb.jpg?nocache=1

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dmeroff, 2014-03-06
@dmeroff

Have you tried running this code? You have a syntax error, so the sublime swears. preg_replace takes as its first argument a string or an array of strings, and if it is a string, then it must be enclosed in single or double quotes.

$new_var= preg_replace('/href="\/uploads/', '123', $var);

C
Codebaker, 2014-03-06
@Codebaker

Try escaping the double quote \"

A
Alexey Sundukov, 2014-03-06
@alekciy

Lights up correctly. preg_replace must have a string as its first argument. Therefore, the second spelling is syntactically correct. Actually, I have it (ubuntu 12.04, Sublime 2.0.2) is shown correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question