JSFiddle - React, Tailwind, and code Playground

JavaScript

var u1 = 'http://www.anywebsite.com/this_is_my_text?some&parameters and segment = "this_is_my_text"';
var u2 = 'http://www.anywebsite.com/this_is_my_textand segment = "this_is_my_text"';

    if(u2.indexOf('segment') !== -1) {
        return alert('found'); 
      }