Skip to content

Commit d55a414

Browse files
committed
Revert "update readme"
This reverts commit 9bbcdca.
1 parent 9bbcdca commit d55a414

File tree

1 file changed

+63
-21
lines changed

1 file changed

+63
-21
lines changed

README.md

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

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

7+
## How to get started
68

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

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

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

13-
$regex ->startOfLine()
14-
->then( "http" )
15-
->maybe( "s" )
16-
->then( "://" )
17-
->maybe( "www." )
18-
->anythingBut( " " )
19-
->endOfLine();
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();
2030

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

22-
if($regex->test("http://github.com"))
23-
echo "valid url";
24-
else
25-
echo "invalid url";
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+
```
2640

41+
### Replacing strings
2742

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

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+
```
3055

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.", "-");
56+
### Shorthand for string replace:
3457

58+
```javascript
59+
var result = VerEx().find( "red" ).replace( "We have a red house", "blue" );
60+
alert( result ); // Outputs "We have a blue house"
3561
```
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)