@@ -10,7 +10,7 @@ class RegExpValidatorTest extends TestCase
1010 public function testValidRegExp ()
1111 {
1212 // Example with an email pattern
13- $ validator = new RegExpValidator ('/ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/ ' );
13+ $ validator = new RegExpValidator ('^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ' );
1414
1515 $ this ->assertTrue ($ validator ->validate ('test@example.com ' ));
1616 $ this ->assertTrue ($ validator ->validate ('user.name+tag@domain.co.uk ' ));
@@ -19,7 +19,7 @@ public function testValidRegExp()
1919 public function testInvalidRegExp ()
2020 {
2121 // Example with an email pattern
22- $ validator = new RegExpValidator ('/ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}$/ ' );
22+ $ validator = new RegExpValidator ('^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}$ ' );
2323
2424 $ this ->assertFalse ($ validator ->validate ('plainaddress ' ));
2525 $ this ->assertFalse ($ validator ->validate ('@no-local-part.com ' ));
@@ -29,12 +29,12 @@ public function testInvalidRegExp()
2929 public function testDifferentPatterns ()
3030 {
3131 // Example with a numeric pattern
32- $ numericValidator = new RegExpValidator ('/ ^\d+$/ ' );
32+ $ numericValidator = new RegExpValidator ('^\d+$ ' );
3333 $ this ->assertTrue ($ numericValidator ->validate ('12345 ' ));
3434 $ this ->assertFalse ($ numericValidator ->validate ('abc123 ' ));
3535
3636 // Example with a specific format (e.g., date in YYYY-MM-DD)
37- $ dateValidator = new RegExpValidator ('/ ^\d{4}-\d{2}-\d{2}$/ ' );
37+ $ dateValidator = new RegExpValidator ('^\d{4}-\d{2}-\d{2}$ ' );
3838 $ this ->assertTrue ($ dateValidator ->validate ('2022-01-01 ' ));
3939 $ this ->assertFalse ($ dateValidator ->validate ('01-01-2022 ' ));
4040 }
0 commit comments