Alex Rivera | Logout

Regex to check for new line

Asked 2012-08-24T14:53:19.147
11

I want to check if an if statement is on one line or the next line without a brace like so:

if (blah === blah)
    do something

or:

if (foo === foo) do something

The regex i have currently is

/\)(?!.*\{)/

But doesnt work. Anyone have any ideas?

To elaborate the only If statement that would not be pulled by this regex is the following:

if (foo === bar)
{
Edit
Report

1 Answer

0

As you want to check this specifically for an if, use this:

(if[ ()\w=]+)\r\n

returns true if the if has a newline and false if not.

answered 2012-08-24T15:01:09.757

Your Answer