/coding/
, você pode procurar o padrão "coding"
em outra string. Isso é poderoso para pesquisar strings únicas, mas é limitado a apenas um padrão. Você pode pesquisar vários padrões usando a alternation
ou o operador OR
: |
. Este operador corresponde aos padrões antes ou depois dele. Por exemplo, se você quisesse combinar "yes"
ou "no"
, o regex desejado é /yes|no/
. Você também pode pesquisar mais do que apenas dois padrões. Você pode fazer isso adicionando mais padrões com mais operadores OR
separando-os, como /yes|no|maybe/
. petRegex
para combinar com os pets "dog"
, "cat"
, "bird"
ou "fish"
. petRegex
deve retornar true
para a string "John has a pet dog."
testString: 'assert(petRegex.test("John has a pet dog."), "Your regex petRegex
should return true
for the string "John has a pet dog."
");'
- text: Seu regex petRegex
deve retornar false
para a string "Emma has a pet rock."
testString: 'assert(!petRegex.test("Emma has a pet rock."), "Your regex petRegex
should return false
for the string "Emma has a pet rock."
");'
- text: Seu regex petRegex
deve retornar true
para a string "Emma has a pet bird."
testString: 'assert(petRegex.test("Emma has a pet bird."), "Your regex petRegex
should return true
for the string "Emma has a pet bird."
");'
- text: Seu regex petRegex
deve retornar true
para a string "Liz has a pet cat."
testString: 'assert(petRegex.test("Liz has a pet cat."), "Your regex petRegex
should return true
for the string "Liz has a pet cat."
");'
- text: Seu regex petRegex
deve retornar false
para a string "Kara has a pet dolphin."
testString: 'assert(!petRegex.test("Kara has a pet dolphin."), "Your regex petRegex
should return false
for the string "Kara has a pet dolphin."
");'
- text: Seu regex petRegex
deve retornar true
para a string "Alice has a pet fish."
testString: 'assert(petRegex.test("Alice has a pet fish."), "Your regex petRegex
should return true
for the string "Alice has a pet fish."
");'
- text: Seu regex petRegex
deve retornar false
para a string "Jimmy has a pet computer."
testString: 'assert(!petRegex.test("Jimmy has a pet computer."), "Your regex petRegex
should return false
for the string "Jimmy has a pet computer."
");'
```