05.01.2013 Views

hide - Understanding jQuery

hide - Understanding jQuery

hide - Understanding jQuery

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The text string. Pattern Return value (Array)<br />

Remember that time that the trees fell down.<br />

The wood crashing through the wall.<br />

Remember the sound that could wake the dead.<br />

But nobody woke up at all.<br />

/Remember/ [“Remember”]<br />

Remember that time that the trees fell down.<br />

The wood crashing through the wall.<br />

Remember the sound that could wake the dead.<br />

But nobody woke up at all.<br />

/Remember/g [“Remember“, “Remember“]<br />

Remember that time that the trees fell down.<br />

The wood crashing through the wall.<br />

Remember the sound that could wake the dead.<br />

But nobody woke up at all.<br />

/wall/g [“wall“]<br />

Remember that time that the trees fell down. /[wall]/g [“a”, ”a”, “l”, “l”, “w”, “w”, “a”...<br />

The wood crashing through the wall.<br />

Remember the sound that could wake the dead.<br />

But nobody woke up at all.<br />

etc]<br />

Remember that time that the trees fell down. /[.]/g [“.”, “.”, “.”,<br />

The wood crashing through the wall.<br />

Remember the sound that could wake the dead.<br />

But nobody woke up at all.<br />

“.”]<br />

Remember that time that the trees fell down. /A-Z/ Only capital letters. A to Z.<br />

The wood crashing through the wall.<br />

Remember the sound that could wake the dead.<br />

But nobody woke up at all.<br />

[“R”, “T”, “R”, “B”]<br />

Remember that time that the trees fell down. /.*/ Match everything until end<br />

The wood crashing through the wall.<br />

of line. Notice that the match<br />

Remember the sound that could wake the dead.<br />

automatically stops at the end<br />

But nobody woke up at all.<br />

of line, the invisible character.<br />

Remember that time that the trees fell down. /.*/g When g is added, however,<br />

The wood crashing through the wall.<br />

the match does not stop at the<br />

Remember the sound that could wake the dead.<br />

But nobody woke up at all.<br />

end of character mark.<br />

If you understand these commands, you will be able to do some interesting things with strings.<br />

However, these examples are far from definitive. There are thousands of different ways ot select<br />

characters from a string using regular expressions.<br />

If you believe regular expressions can help you with your web project, refer to Jan Goyvaerts<br />

regular expression website at this URL: www.regular-expressions.info This is an excellent free<br />

resource to further explore regular expressions.<br />

120

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!