htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Regular Expressions in Dreamweaver
PostPosted: 03 Nov 2006 07:49 
Offline

Joined: 01 Nov 2006 05:19
Posts: 26
Regular expressions in Dreamweaver
Regular expressions are patterns that describe character combinations in text. Use them in your code searches to help describe concepts such as "lines that begin with ‘var’" and "attribute values that contain a number." For more information on searching, see Searching and replacing tags and attributes.

The following table lists the special characters in regular expressions, their meanings, and usage examples. To search for text containing one of the special characters in the table, "escape" the special character by preceding it with a backslash. For example, to search for the actual asterisk in the phrase some conditions apply*, your search pattern might look like this: apply\*. If you don’t escape the asterisk, you’ll find all the occurrences of "apply" (as well as any of "appl", "applyy", and "applyyy"), not just the ones followed by an asterisk.




\f------------Form feed.
\n------------Line feed.
\r------------Carriage return.
\t------------A tab.

^------------Beginning of input or line.
Code:
^T matches "T" in "This good earth" but not in "Uncle Tom's Cabin"




$------------End of input or line.
Code:
h$ matches "h" in "teach" but not in "teacher"





*------------The preceding character 0 or more times.
Code:
um* matches "um" in "rum", "umm" in "yummy", and "u" in "huge"





+------------The preceding character 1 or more times.
Code:
um+ matches "um" in "rum" and "umm" in "yummy" but nothing in "huge"





?------------The preceding character at most once (that is, indicates that the preceding character is optional).
Code:
st?on matches "son" in "Johnson" and "ston" in "Johnston" but nothing in "Appleton" or "tension"





.------------Any single character except newline.
Code:
.an matches "ran" and "can" in the phrase "bran muffins can be tasty"





x|y------------Either x or y.
Code:
FF0000|0000FF matches "FF0000" in bgcolor="#FF0000" and "0000FF'" in font color="#0000FF"





{n}------------Exactly n occurrences of the preceding character.
Code:
o{2} matches "oo" in "loom" and the first two o's in "mooooo" but nothing in "money"





{n,m}------------At least n, and at most m, occurrences of the preceding character.
Code:
F{2,4} matches "FF" in "#FF0000" and the first four F's in #FFFFFF





[abc]------------Any one of the characters enclosed in the brackets. Specify a range of characters with a hyphen (for example, [a-f] is equivalent to [abcdef]).
Code:
[e-g] matches "e" in "bed", "f" in "folly", and "g" in "guard"





[^abc]------------Any character not enclosed in the brackets. Specify a range of characters with a hyphen (for example, [^a-f] is equivalent to [^abcdef]).
Code:
[^aeiou] initially matches "r" in "orange", "b" in "book", and "k" in "eek!"





\b------------A word boundary (such as a space or carriage return).
Code:
\bb matches "b" in "book" but nothing in "goober" or "snob"





\B------------Anything other than a word boundary.
Code:
\Bb matches "b" in "goober" but nothing in "book"





\d------------Any digit character. Equivalent to [0-9].
Code:
\d matches "3" in "C3PO" and "2" in "apartment 2G"





\D------------Any nondigit character. Equivalent to [^0-9].
Code:
\D matches "S" in "900S" and "Q" in "Q45"





\s------------Any single white-space character, including space, tab, form feed, or line feed.
Code:
\sbook matches "book" in "blue book" but nothing in "notebook"





\S------------Any single non-white-space character.
Code:
\Sbook matches "book" in "notebook" but nothing in "blue book"





\w------------Any alphanumeric character, including underscore. Equivalent to [A-Za-z0-9_].
Code:
b\w* matches "barking" in "the barking dog" and both "big" and "black" in "the big black dog"





\W------------Any non-alphanumeric character. Equivalent to [^A-Za-z0-9_].
Code:
\W matches "&" in "Jake&Mattie" and "%" in "100%"       




Use parentheses to set off groupings within the regular expression to be referred to later. Then use $1, $2, $3, and so on in the Replace With field to refer to the first, second, third, and later parenthetical groupings.

NOTE

In the Search For text box, to refer to a parenthetical grouping earlier in the regular expression, use \1, \2, \3, and so on instead of $1, $2, $3.


For example, searching for (\d+)\/(\d+)\/(\d+) and replacing it with $2/$1/$3 swaps the day and month in a date separated by slashes, thereby converting between American-style dates and European-style dates.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB