javascript - Regex for finding a specific pattern in a string -


I want to write a regex if a string has ]] [[. For pre: [[T]] [[T]] .

But if I try to use the pattern:

  RegExp (/] \] \ [? = \ [\ [] /)   

for testing [[t]] [[t]] , console displays unknown ')': < P>

Why do you have a syntax error:

You can call ( to \ ( , so you have unmatched '' '' in the error \ (? = \ [\ []

How to fix it:

The best way to do this really depends on you.

If you just want to check that In the string, ]] [[[/ code>, do not use a regex:

  if (yourString.indexOf (')] [[' ']] == -1 ) {// do something}   

If you really want to use a regex, you can [ s but ] to avoid s:

  if (/ $] <<< =. Test ((its string)) {// do something}   

If you really Want to use regex and [[:

  do not want to capture, then (/]] (? = \ [\ [] / Test (yourString)) {// do something}   

If you select [[ and ]] (like [[ T]] ):

  if (/ \ [[[[[[[[\\]] *]] /. Test (your string)} {// do something}   

If you want to check two [[..]] string back-to-back:

  if (/ [SA [[[^ [\]] *]] / test (your string)} {// do something}   

If you have a If you want to check for [[.. ..]] string, then after the exact same string ( [[t]] [[t]] but not [[foo]] [[bar]] ):

  if (/ ([[[[[^ [[]] *]]) \ 1 / .test (yourS Tring) together with a group of unit tests to show how each of them does the work   



Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -