Skip to content

Commit 9bbcdca

Browse files
committed
update readme
1 parent 34ce654 commit 9bbcdca

File tree

1 file changed

+21
-63
lines changed

1 file changed

+21
-63
lines changed

README.md

Lines changed: 21 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,35 @@
1-
VerbalExpressions v0.1
2-
=====================
1+
##PHPVerbalExpressions
2+
- ported from [VerbalExpressions](https://github.com/jehna/VerbalExpressions)
33

4-
## JavaScript Regular Expressions made easy
5-
VerbalExpressions is a JavaScript library that helps to construct difficult regular expressions.
4+
VerbalExpressions is a PHP library that helps to construct hard regular expressions.
65

7-
## How to get started
86

9-
Include the library and you're good to go!
10-
```HTML
11-
<script src="VerbalExpressions.js"></script>
12-
```
13-
14-
## Examples
7+
```php
158

16-
Here's a couple of simple examples to give an idea of how VerbalExpressions works:
9+
// some tests
1710

18-
### Testing if we have a valid URL
11+
$regex = new VerEx;
1912

20-
```javascript
21-
// Create an example of how to test for correctly formed URLs
22-
var tester = VerEx()
23-
.startOfLine()
24-
.then( "http" )
25-
.maybe( "s" )
26-
.then( "://" )
27-
.maybe( "www." )
28-
.anythingBut( " " )
29-
.endOfLine();
13+
$regex ->startOfLine()
14+
->then( "http" )
15+
->maybe( "s" )
16+
->then( "://" )
17+
->maybe( "www." )
18+
->anythingBut( " " )
19+
->endOfLine();
3020

31-
// Create an example URL
32-
var testMe = "https://www.google.com";
3321

34-
// Use RegExp object's native test() function
35-
if( tester.test( testMe ) ) alert( "We have a correct URL "); // This output will fire
36-
else alert( "The URL is incorrect" );
37-
38-
console.log( tester ); // Ouputs the actual expression used: /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/
39-
```
22+
if($regex->test("http://github.com"))
23+
echo "valid url";
24+
else
25+
echo "invalid url";
4026

41-
### Replacing strings
4227

43-
```javascript
44-
// Create a test string
45-
var replaceMe = "Replace bird with a duck";
28+
echo "<pre>". $regex->getRegex() ."</pre>";
4629

47-
// Create an expression that seeks for word "bird"
48-
var expression = VerEx().find( "bird" );
49-
50-
// Execute the expression like a normal RegExp object
51-
var result = replaceMe.replace( expression, "duck" );
52-
53-
alert( result ); // Outputs "Replace duck with a duck"
54-
```
5530

56-
### Shorthand for string replace:
31+
echo $regex ->clean(array("modifiers"=> "m","replaceLimit"=>4))
32+
->find(' ')
33+
->replace("This is a small test http://somesite.com and some more text.", "-");
5734

58-
```javascript
59-
var result = VerEx().find( "red" ).replace( "We have a red house", "blue" );
60-
alert( result ); // Outputs "We have a blue house"
6135
```
62-
63-
## API documentation
64-
65-
You can find the API documentation at the [wiki pages](https://github.com/jehna/VerbalExpressions/wiki).
66-
67-
## A little word for a big help
68-
I'd like to promote a special thank-you to [Ben Nadel][ben-nadel] for his [great article about extending native JS objects][extending]
69-
70-
## Contributions
71-
Clone the repo and fork:
72-
`git clone https://github.com/jehna/VerbalExpressions.git`.
73-
74-
Pull requests are warmly welcome!
75-
76-
[ben-nadel]:http://www.bennadel.com/
77-
[extending]:http://www.bennadel.com/blog/2292-Extending-JavaScript-Arrays-While-Keeping-Native-Bracket-Notation-Functionality.htm

0 commit comments

Comments
 (0)