The End of Word Sequence

The \> sequence is used to match the end of a word boundary in a regular expression search. For example, given the code below,

 

#define threshold_low        2400

#define threshold_high       4800

#define threshold_mid        3600

#define number_1             1

 

If we wanted to match the three threshold levels but not number_1, we could use the following expression:

 

[A-Za-z_]+\>[ \t]+[0-9]+

 

This expression will match the following:

 

#define.threshold_low        2400.

#define.threshold_high       4800.

#define.threshold_mid        3600.

#define number_1             1.

 

Understanding the Expression

Let's break down the expression to understand how it works. The first part is highlighted below:

 

[A-Za-z_]+\>[ \t]+[0-9]+

 

This sequence means match any sequences of characters in the set A-Z, a-z, or _ that marks the end of a world as indicated by the \> sequence. Note that the number_1 is not highlighted because it ends with a number that is not in our defined set. Thus we would get the following matches:

 

#define.threshold_low        2400.

#define.threshold_high       4800.

#define.threshold_mid        3600.

#define number_1             1

 

The second part,

 

[A-Za-z_]+\>[ \t]+[0-9]+

 

extends our match to include any whitespace characters that separate our threshold name and its defined value which yields the selection:

 

#define.threshold_low........2400.

#define.threshold_high.......4800.

#define.threshold_mid........3600.

#define number_1             1

  

The last part of the expression extends the selection to match the value of the threshold as follows:

 

[A-Za-z_]+\>[ \t]+[0-9]+

 

giving us our final selection:

 

#define.threshold_low........2400..

#define.threshold_high.......4800..

#define.threshold_mid........3600..

#define number_1             1

 

 

  

Back: Start of Word

Forward: Start and End Regions