Skip to content

Commit 5405c33

Browse files
committed
Update README.md
1 parent 00492fc commit 5405c33

1 file changed

Lines changed: 19 additions & 26 deletions

File tree

README.md

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1-
# StringContainsOperators
1+
![Swift](https://github.com/Tavernari/StringContainsOperators/actions/workflows/swift.yml/badge.svg?branch=main)
2+
[![Maintainability](https://api.codeclimate.com/v1/badges/29ffa494572357c62162/maintainability)](https://codeclimate.com/github/Tavernari/StringContainsOperators/maintainability)
3+
[![Test Coverage](https://api.codeclimate.com/v1/badges/29ffa494572357c62162/test_coverage)](https://codeclimate.com/github/Tavernari/StringContainsOperators/test_coverage)
24

3-
StringContainsOperators is a Swift library for creating and evaluating complex string predicates using custom operators. This library provides an easy-to-use and flexible solution for matching strings against complex patterns.
5+
# 🐞 StringContainsOperators
46

5-
## How to Use
7+
StringContainsOperators is a Swift library that simplifies searching for multiple strings within a given text. By using custom infix operators and predicates, you can create complex and flexible search patterns that make it easy to find if strings exist in your text.
68

7-
The library provides three main components: custom operators, an enum type, and an extension to the String class.
9+
## Usage
810

9-
## Custom Operators
10-
11-
StringContainsOperators provides two custom operators: || and &&. These operators are used to create OR and AND predicates, respectively, between two strings or between a string and another predicate.
12-
13-
For example, you can create an OR predicate between two strings as follows:
14-
15-
```swift
16-
let predicate = "hello" || "world"
17-
```
18-
This creates a predicate that matches any string that contains either "hello" or "world". Similarly, you can create an AND predicate between two strings like this:
11+
Here's a quick example of how you can use StringContainsOperators:
1912

2013
```swift
21-
let predicate = "hello" && "world"
22-
```
23-
This creates a predicate that matches any string that contains both "hello" and "world".
14+
import StringContainsOperators
2415

25-
## Enum Type
16+
let text = "The quick brown fox jumps over the lazy dog."
2617

27-
The resulting predicate is represented by an enum type called StringPredicate. This enum type can be either a base predicate, an OR predicate, or an AND predicate.
18+
// Check if text contains "quick" OR "jumps"
19+
let result1 = text.contains("quick" || "jumps")
20+
print(result1) // true
2821

29-
## Extension to String
22+
// Check if text contains "fox" AND "dog"
23+
let result2 = text.contains("fox" && "dog")
24+
print(result2) // true
3025

31-
The contains() function, which is an extension of the String class, is used to evaluate whether a given string satisfies a particular predicate. The function takes a StringPredicate as input and returns a boolean value indicating whether the predicate is true or false.
32-
33-
```swift
34-
let result = "hello world".contains("hello" || "world")
35-
print(result) // true
26+
// Check if text contains "fox" AND ("jumps" OR "swift")
27+
let result3 = text.contains("fox" && ("jumps" || "swift"))
28+
print(result3) // true
3629
```
3730

3831
## How to Install
@@ -57,4 +50,4 @@ pod 'StringContainsOperators', '~> 1.0'
5750

5851
Contributions to StringContainsOperators are welcome! Before making a pull request, please open an issue to discuss your proposed changes. We follow the GitHub Flow for our development process.
5952

60-
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
53+
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

0 commit comments

Comments
 (0)