You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -907,15 +907,15 @@ In this example, we precisely match "alt=" using the `exact` method. We then cre
907
907
908
908
The `orPattern` method also accepts a quantifier as its **second argument** (after callback), applying the same [quantifier logic](#quantifier-values) as elsewhere in EloquentRegex. This feature adds another layer of flexibility, allowing you to specify how many times either pattern should be present.
909
909
910
-
## Raw Methods🧩
910
+
## Raw Methods🧩
911
911
912
912
When working with regular expressions, there are times you'll need to insert a segment of raw regex directly into your pattern. This might be due to the complexity of the pattern or simply because you're integrating an existing regex snippet. EloquentRegex accommodates this need with specific methods designed to seamlessly integrate raw regex patterns into your larger expressions.
913
913
914
914
#### Adding Raw Regex Patterns
915
915
916
916
The `addRawRegex` method allows you to insert any raw regex directly into your pattern. This is particularly useful for incorporating standard regex snippets without modification.
917
917
918
-
**Example: Matching a Social Security Number (SSN)**
918
+
**_Example: Matching a Social Security Number (SSN)_**
919
919
920
920
```php
921
921
// Directly adds a raw regex pattern for an SSN
@@ -931,7 +931,7 @@ This method is straightforward and ensures that your EloquentRegex pattern can a
931
931
932
932
Sometimes, you may want to include a raw regex snippet as part of a larger pattern without capturing its match. The `addRawNonCapturingGroup` method wraps the provided raw regex in a non-capturing group, allowing it to participate in the match without affecting the captured groups.
933
933
934
-
**Example: Adding Digits Followed by a Specific Letter**
934
+
**_Example: Adding Digits Followed by a Specific Letter_**
935
935
936
936
```php
937
937
// Wraps digits in a non-capturing group and expects an 'A' immediately after
@@ -949,7 +949,8 @@ In the world of regular expressions, greediness refers to the tendency of quanti
949
949
950
950
The `lazy()` method modifies the behavior of quantifiers that follow it in the pattern, making them match as few characters as possible. This is particularly useful when you want to extract specific segments from a larger block of text without capturing unnecessary parts.
951
951
952
-
**Example: Extracting "Secret Coded" Messages from Text**
952
+
**_Example: Extracting "Secret Coded" Messages from Text_**
953
+
953
954
Consider a situation where you need to extract coded messages enclosed in curly braces and preceded by a specific keyword within a larger text. Using the greedy approach might lead to capturing more text than intended, including text between messages. The `lazy()` method ensures that only the content directly within the braces, following the keyword, is matched.
// Expected to extract ['message one', 'another hidden text'] as separate matches
968
-
968
+
// Extracts ['message one', 'another hidden text'] as separate matches
969
969
```
970
970
971
971
In this example, without the `lazy()` method, the pattern might greedily match from the first `{secret: ` to the last `}`, including everything in between as a single match (`message one} more text {secret: another hidden text`). By applying `lazy()`, the pattern instead matches the smallest possible string that satisfies the pattern within each set of curly braces, effectively separating the messages.
0 commit comments