is there a regex to replace this if condition

I have three string and i need to check if one of them contains the other 2 in the same order given, right now i am using alot of conditions to achive this, is there a way to simplify it using regex?

here is the code:

var a = '**';
var b = '##';
var phrase = '**Lorem ipsum dolor sit amet##';

if(phrase.includes(a) && phrase.includes(b) && (phrase.indexOf(a) < phrase.indexOf(b))) {
  // add logic

Source: JavaSript – Stack Overflow

November 21, 2021
Category : News
Tags: conditional-statements | indexof | javascript | regex

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.