Search for words in upper-case

A discussion of how to use EasyPatterns, EasyPattern Helper and using the EasyPattern library.

Moderator: DataMystic Support

apportum
Posts: 9
Joined: Thu Aug 20, 2009 5:00 pm

Search for words in upper-case

Postby apportum » Fri May 02, 2014 6:05 am

Using EasyPatterns, I am attempting to create a Regular Expression that will locate the first or, under some circumstances, the second instance in a string of text that is all UPPERCASE.

Here is one of the many attempts I've made to craft such an RE. All of them have failed so far.

"[capture(uppercaseLetter), capture(1+ chars)]"

Here are two examples of my source material:

EXAMPLE 1:

cellspacing="0" cellpadding="0" style='page-break-inside: avoid'><tr><td align="center"

width="100%" colspan="6" height="25"><div id="datafont">&nbsp;BIG SAMPLE

COMPANY, 8790 JIMMY MOUNT TRAIL PORTLAND, ME 03047 800-555-1212 OR

673-459-8912</div></td></tr><tr><td width="40%" rowspan="2"><div

id="datafont">&nbsp;&nbsp;&nbsp;

EXAMPLE 2:

<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="BOLDSILVERCENTER">
<br>&nbsp;

GIGANTIC RAZZMATAZZ CREATIONS&nbsp;&nbsp;,&nbsp;

4738 MOONCRATER RD&nbsp;&nbsp;

ARLINGTON&nbsp;&nbsp;,&nbsp;

AL&nbsp;&nbsp;



17947&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;



PH : 8449387287

&nbsp;&nbsp;

<br>&nbsp; </td>
</tr>
</table>

In Example 1, I want to create an expression that will capture the first instance of all UPPERCASE characters in some HTML. (There is no UPPERCASE in the extracted portion prior to this instance.) I want to capture the UPPERCASE text up to the comma (i.e. "BIG SAMPLE COMPANY").

In Example 2, I want to ignore the first instance of UPPERCASE ("<td class="BOLDSILVERCENTER">") and extract or captur the second instance of UPPERCASE up to the first "&nbsp".

I have been studying the EasyPatterns help file and reference and tried everything.

I obviously just don't get it.

What am I doing wrong or failing to do? (Thank you in advance for your help.)

Jerry

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Search for words in upper-case

Postby DataMystic Support » Mon May 19, 2014 4:12 pm

Hi Jerry,

These should do the trick:

Example 1.

Code: Select all

[ capture(longest 1+ uppercaseLetter or space)  as 'wanted_text' ]


Example 2.

You still need to identify the first uppercase section so that you can then ignore it.

Code: Select all

[ 2+ uppercaseLetter, 1+ chars, capture(longest 1+ uppercaseLetter or space) as 'wanted_text' ]
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “EasyPatterns Support”

Who is online

Users browsing this forum: No registered users and 1 guest