@@ -6,36 +6,122 @@ Scala regex collection
6
6
7
7
Scala-regex-collection is a pure scala regex collection
8
8
## Add the library to your project
9
- ` libraryDependencies += "com.github.gekomad" %% "scala-regex-collection" % "0.0.1 " `
9
+ ` libraryDependencies += "com.github.gekomad" %% "scala-regex-collection" % "0.0.2 " `
10
10
11
11
## Using Library
12
12
13
13
### Patterns
14
14
15
15
You can use defined patterns or you can define yours
16
16
17
- - [ Email] ( https://github.com/gekomad/scala-regex-collection/wiki/EMAIL )
18
- - [ UUID] ( https://github.com/gekomad/scala-regex-collection/wiki/UUID )
19
- - [ IP] ( https://github.com/gekomad/scala-regex-collection/wiki/IP )
20
- - [ IP_6] ( https://github.com/gekomad/scala-regex-collection/wiki/IP_6 )
21
- - [ SHA1] ( https://github.com/gekomad/scala-regex-collection/wiki/SHA1 )
22
- - [ SHA256] ( https://github.com/gekomad/scala-regex-collection/wiki/SHA256 )
23
- - [ URLs] ( https://github.com/gekomad/scala-regex-collection/wiki/URLs )
24
- - [ HEX] ( https://github.com/gekomad/scala-regex-collection/wiki/HEX )
25
- - [ Bitcon Address] ( https://github.com/gekomad/scala-regex-collection/wiki/Bitcon-Address )
26
- - [ US phone number] ( https://github.com/gekomad/scala-regex-collection/wiki/US-phone-number )
27
- - [ 24 Hours time] ( https://github.com/gekomad/scala-regex-collection/wiki/24-Hours-time )
28
- - [ Youtube] ( https://github.com/gekomad/scala-regex-collection/wiki/Youtube )
29
- - [ Crontab expression] ( https://github.com/gekomad/scala-regex-collection/wiki/Crontab-expression )
30
- - [ Italian fiscal code] ( https://github.com/gekomad/scala-regex-collection/wiki/Italian-fiscal-code )
31
- - [ Italian partita iva] ( https://github.com/gekomad/scala-regex-collection/wiki/Italian-partita-iva )
32
- - [ LocalDateTime] ( https://github.com/gekomad/scala-regex-collection/wiki/LocalDateTime )
33
- - [ LocalDate] ( https://github.com/gekomad/scala-regex-collection/wiki/LocalDate )
34
- - [ LocalTime] ( https://github.com/gekomad/scala-regex-collection/wiki/LocalTime )
35
- - [ OffsetDateTime] ( https://github.com/gekomad/scala-regex-collection/wiki/OffsetDateTime )
36
- - [ OffsetTime] ( https://github.com/gekomad/scala-regex-collection/wiki/OffsetTime )
37
- - [ ZonedDateTime] ( https://github.com/gekomad/scala-regex-collection/wiki/ZonedDateTime )
17
+ href
18
+ Email
38
19
20
+ - [ Email] ( https://github.com/gekomad/scala-regex-collection/wiki/Email ) ($abc@</span >def</span >.c)
21
+ - [ Email1] ( https://github.com/gekomad/scala-regex-collection/wiki/Email1 ) (abc@</span >def</span >.com)
22
+ - [ Email simple] ( https://github.com/gekomad/scala-regex-collection/wiki/EmailSimple ) ($@</span >%</span >.$)
23
+
24
+ Ciphers
25
+
26
+ - [ UUID] ( https://github.com/gekomad/scala-regex-collection/wiki/UUID ) (1CC3CCBB-C749-3078-E050-1AACBE064651)
27
+ - [ MD5] ( https://github.com/gekomad/scala-regex-collection/wiki/MD5 ) (23f8e84c1f4e7c8814634267bd456194)
28
+ - [ SHA1] ( https://github.com/gekomad/scala-regex-collection/wiki/SHA1 ) (1c18da5dbf74e3fc1820469cf1f54355b7eec92d)
29
+ - [ SHA256] ( https://github.com/gekomad/scala-regex-collection/wiki/SHA256 ) (000020f89134d831f48541b2d8ec39397bc99fccf4cc86a3861257dbe6d819d1)
30
+
31
+ URL, IP, MAC Address
32
+
33
+ - [ IP] ( https://github.com/gekomad/scala-regex-collection/wiki/IP ) (10.192.168.1)
34
+ - [ IP_6] ( https://github.com/gekomad/scala-regex-collection/wiki/IP_6 ) (2001:db8:a0b:12f0::1)
35
+ - [ URLs] ( https://github.com/gekomad/scala-regex-collection/wiki/URLs ) (http://</span >abc.def</span >.com)
36
+ - [ Youtube] ( https://github.com/gekomad/scala-regex-collection/wiki/Youtube ) (https://</span >www</span >.youtube</span >.com/watch?v=9bZkp7q19f0)
37
+ - [ Facebook] ( https://github.com/gekomad/scala-regex-collection/wiki/Facebook ) (https://</span >www</span >.facebook.</span >com/thesimpsons - https://</span >www</span >.facebook.</span >com/pages/)
38
+ - [ Twitter] ( https://github.com/gekomad/scala-regex-collection/wiki/Twitter ) (https://</span >twitter</span >.com/rtpharry)
39
+ - [ MAC Address] ( https://github.com/gekomad/scala-regex-collection/wiki/MACAddress ) (fE:dC:bA:98:76:54)
40
+
41
+ HEX
42
+
43
+ - [ HEX] ( https://github.com/gekomad/scala-regex-collection/wiki/HEX ) (#F0F0F0 - 0xF0F0F0)
44
+
45
+ Bitcoin
46
+
47
+ - [ Bitcon Address] ( https://github.com/gekomad/scala-regex-collection/wiki/Bitcon-Address ) (3Nxwenay9Z8Lc9JBiywExpnEFiLp6Afp8v)
48
+
49
+ Phone numbers
50
+
51
+ - [ US phone number] ( https://github.com/gekomad/scala-regex-collection/wiki/US-phone-number ) (555-555-5555 - (416)555-3456)
52
+ - [ Italian Mobile Phone] ( https://github.com/gekomad/scala-regex-collection/wiki/ItalianMobilePhone ) (+393471234561 - 3381234561)
53
+ - [ Italian Phone] ( https://github.com/gekomad/scala-regex-collection/wiki/ItalianPhone ) (02 645566 - 02/583725 - 02-583725)
54
+
55
+ Date time
56
+
57
+ - [ 24 Hours time] ( https://github.com/gekomad/scala-regex-collection/wiki/24-Hours-time ) (23:50:00)
58
+ - [ LocalDateTime] ( https://github.com/gekomad/scala-regex-collection/wiki/LocalDateTime ) (2000-12-31T11:21:19)
59
+ - [ LocalDate] ( https://github.com/gekomad/scala-regex-collection/wiki/LocalDate ) (2000-12-31)
60
+ - [ LocalTime] ( https://github.com/gekomad/scala-regex-collection/wiki/LocalTime ) (11:21:19)
61
+ - [ OffsetDateTime] ( https://github.com/gekomad/scala-regex-collection/wiki/OffsetDateTime ) (2011-12-03T10:15:30+01:00)
62
+ - [ OffsetTime] ( https://github.com/gekomad/scala-regex-collection/wiki/OffsetTime ) (10:15:30+01:00)
63
+ - [ ZonedDateTime] ( https://github.com/gekomad/scala-regex-collection/wiki/ZonedDateTime ) (2016-12-02T11:15:30-05:00)
64
+ - [ MDY] ( https://github.com/gekomad/scala-regex-collection/wiki/MDY ) (1/12/1902 - 12/31/1902)
65
+ - [ MDY2] ( https://github.com/gekomad/scala-regex-collection/wiki/MDY2 ) (1-12-1902)
66
+ - [ MDY3] ( https://github.com/gekomad/scala-regex-collection/wiki/MDY3 ) (01/01/1900 - 12/31/9999)
67
+ - [ MDY4] ( https://github.com/gekomad/scala-regex-collection/wiki/MDY4 ) (01-12-1902 - 12-31-2018)
68
+ - [ DMY] ( https://github.com/gekomad/scala-regex-collection/wiki/DMY ) (1/12/1902)
69
+ - [ DMY2] ( https://github.com/gekomad/scala-regex-collection/wiki/DMY2 ) (12-31-1902 - 1-12-1902)
70
+ - [ DMY3] ( https://github.com/gekomad/scala-regex-collection/wiki/DMY3 ) (01/12/1902 - 01/12/1902)
71
+ - [ DMY4] ( https://github.com/gekomad/scala-regex-collection/wiki/DMY4 ) (01-12-1902 - 01-12-1902)
72
+ - [ Time] ( https://github.com/gekomad/scala-regex-collection/wiki/Time ) (8am - 8 pm - 11 PM - 8:00 am)
73
+
74
+ Crontab
75
+
76
+ - [ Crontab expression] ( https://github.com/gekomad/scala-regex-collection/wiki/Crontab-expression ) (5 4 * * * )
77
+
78
+ Codes
79
+
80
+ - [ Italian fiscal code] ( https://github.com/gekomad/scala-regex-collection/wiki/Italian-fiscal-code ) (BDAPPP14A01A001R)
81
+ - [ Italian VAT code] ( https://github.com/gekomad/scala-regex-collection/wiki/ItalianVAT ) (13297040362)
82
+ - [ Italian Iban] ( https://github.com/gekomad/scala-regex-collection/wiki/ItalianIban ) (IT28 W800 0000 2921 0064 5211 151 - IT28W8000000292100645211151)
83
+ - [ US states] ( https://github.com/gekomad/scala-regex-collection/wiki/USstates ) (FL - CA)
84
+ - [ US states1] ( https://github.com/gekomad/scala-regex-collection/wiki/USstates1 ) (Connecticut - Colorado)
85
+ - [ US zip code] ( https://github.com/gekomad/scala-regex-collection/wiki/USZipCode ) (43802)
86
+ - [ US streets] ( https://github.com/gekomad/scala-regex-collection/wiki/USStreets ) (123 Park Ave Apt 123 New York City, NY 10002)
87
+ - [ US street numbers] ( https://github.com/gekomad/scala-regex-collection/wiki/USStreetNumber ) (P.O. Box 432)
88
+ - [ Italian zip code] ( https://github.com/gekomad/scala-regex-collection/wiki/ItalianZipCode ) (23887)
89
+ - [ German streets] ( https://github.com/gekomad/scala-regex-collection/wiki/GermanStreet ) (Mühlenstr. 33)
90
+
91
+ Concurrency
92
+
93
+ - [ USD Currency] ( https://github.com/gekomad/scala-regex-collection/wiki/USD-Currency ) ($1.00 - 1,500.00)
94
+ - [ EUR Currency] ( https://github.com/gekomad/scala-regex-collection/wiki/EurCurrency ) (0,00 € - 133,89 EUR - 133,89 EURO)
95
+ - [ YEN Currency] ( https://github.com/gekomad/scala-regex-collection/wiki/YenCurrency ) (¥1.00 - 15.00 - ¥-1213,120.00)
96
+
97
+ Strings
98
+
99
+ - [ Not ASCII] ( https://github.com/gekomad/scala-regex-collection/wiki/NotASCII ) (テスト。)
100
+ - [ Single char ASCII] ( https://github.com/gekomad/scala-regex-collection/wiki/SingleChar ) (A)
101
+ - [ A-Z string] ( https://github.com/gekomad/scala-regex-collection/wiki/AZString ) (abc)
102
+ - [ String and number] ( https://github.com/gekomad/scala-regex-collection/wiki/StringAndNumber ) (a1)
103
+ - [ ASCII string] ( https://github.com/gekomad/scala-regex-collection/wiki/AsciiString ) (a1%)
104
+
105
+ Logs
106
+
107
+ - [ Apache error] ( https://github.com/gekomad/scala-regex-collection/wiki/ApacheError ) ([ Fri Dec 16 02:25:55 2005] [ error] [ client 1.2.3.4] Client sent malformed Host header)
108
+
109
+ Numbers
110
+
111
+ - [ Number1] ( https://github.com/gekomad/scala-regex-collection/wiki/Number1 ) (99.99 - 1.1 - .99)
112
+ - [ Unsigned32] ( https://github.com/gekomad/scala-regex-collection/wiki/Unsigned32 ) (0 - 122 - 4294967295)
113
+ - [ Signed] ( https://github.com/gekomad/scala-regex-collection/wiki/Signed ) (-10 - +122 - 99999999999999999999999999)
114
+ - [ Percentage] ( https://github.com/gekomad/scala-regex-collection/wiki/Percentage ) (10%)
115
+ - [ Scientific] ( https://github.com/gekomad/scala-regex-collection/wiki/Scientific ) (-2.384E-03)
116
+ - [ Single number] ( https://github.com/gekomad/scala-regex-collection/wiki/SingleNumber ) (1)
117
+ - [ Celsius] ( https://github.com/gekomad/scala-regex-collection/wiki/Celsius ) (-2.2 °C)
118
+ - [ Fahrenheit] ( https://github.com/gekomad/scala-regex-collection/wiki/Fahrenheit ) (-2.2 °F)
119
+
120
+ Coordinates
121
+
122
+ - [ Coordinate] ( https://github.com/gekomad/scala-regex-collection/wiki/Coordinate ) (N90.00.00 E180.00.00)
123
+ - [ Coordinate1] ( https://github.com/gekomad/scala-regex-collection/wiki/Coordinate1 ) (45°23'36.0" N 10°33'48.0" E)
124
+ - [ Coordinate2] ( https://github.com/gekomad/scala-regex-collection/wiki/Coordinate2 ) (12:12:12.223546"N - 15:17:6"S - 12°30'23.256547"S)
39
125
40
126
41
127
## Use the library
@@ -54,7 +140,7 @@ assert(validate[MD5]("fc42757b4142b0474d35fcddb228b304") == Some("fc42757b4142b0
54
140
assert(validate[LocalDateTime]("2000-12-31T11:21:19") == Some("2000-12-31T11:21:19"))
55
141
```
56
142
57
- ### Find all matched strings
143
+ ### findAll
58
144
Example extracting all emails from a string
59
145
```
60
146
import com.github.gekomad.regexcollection.Email
65
151
assert(findAll[Email]("ddddd") == List())
66
152
```
67
153
154
+ ### findFirst
155
+ Example extracting first email from a string
156
+ ```
157
+ trait Bar
158
+ import com.github.gekomad.regexcollection.Validate.findFirst
159
+ import com.github.gekomad.regexcollection.Validate.findFirstIgnoreCase
160
+ import com.github.gekomad.regexcollection.Collection.Validator
161
+
162
+ implicit val myValidator = Validator[Bar]("""Bar@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*""")
163
+
164
+
165
+ ```
166
+
68
167
### Get pattern
69
168
Returns the current pattern used for that type, for example for Email type:
70
169
```
@@ -113,10 +212,11 @@ assert(validateIgnoreCase[Bar]("bar foo") == Some("bar foo"))
113
212
114
213
```
115
214
116
- ### Find all matched strings
215
+ ### findAllIgnoreCase
117
216
118
217
Retrieve all emails using findAll and findAllCaseSensitive
119
218
219
+
120
220
```
121
221
trait Bar
122
222
import com.github.gekomad.regexcollection.Collection.Validator
133
233
### Using a function pattern
134
234
135
235
Instead of using a regular expression to match a string it's possible defining a function pattern
236
+
237
+ Example matching even numbers
238
+
136
239
```
137
240
trait Foo
138
241
@@ -167,4 +270,8 @@ with the License. You may obtain a copy of the License at
167
270
168
271
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
169
272
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
170
- See the License for the specific language governing permissions and limitations under the License.
273
+ See the License for the specific language governing permissions and limitations under the License.
274
+
275
+ ## Special Thanks ##
276
+
277
+ To [ regexlib.com] ( http://regexlib.com )
0 commit comments