Expressions Flashcards

1
Q

Regular expressions

A

-Used in programming languages to match parts of strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Test method

A

-Many ways to test regexes.

Code:
-.test()
- let myString = "Hello, World!";
let myRegex = /Hello/;
let result = myRegex.test(myString); // Change this line

console.log(result);

  • Applies to strings placed in the ()
  • Returns true or false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Match literal strings with different possibilities

A
  • Use the alternation or OR operator
  • Matches patterns either before or after it
  • Can search for more than one pattern (add more OR operators)

Code:
‘|’

myPetRegex = /cat|bird|dog|fish/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly