0

I am trying to grab specific usernames from a training portal:

So far I have created the code, which selects all emails that contains EXAMPLE.com (example below)

Can somebody adjust this code, so it would select '(example.com'), ('example.com'), ('example3.com')?

See code below:

jQuery('tr').each((index, el) => { var txt = $(el).text() if ($(el).find('tr').length === 0 && txt.indexOf('EXAMPLE.com') > -1) { $(el).find('input').click() } }
c0tt
  • 1
  • 2
  • Unfortunatelly stackoverflow is not a code generator, but you need to use indexOf with regex, take a look to this post: https://stackoverflow.com/questions/273789/is-there-a-version-of-javascripts-string-indexof-that-allows-for-regular-expr – Brank Victoria Oct 15 '18 at 11:42

1 Answers1

0

You need to use either a regex or more "ifs" to achieve what you want. Here's an example(.com, hehe) with your own code.

jQuery('tr')
  .each((index, el) => { 
    var txt = $(el).text();
    var re = /example3?\.com/i; // adjust regex as needed.
    if (!$(el).find('tr').length && re.test(txt) { 
      $(el).find('input').click() 
    } 
 })