<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://regexadvice.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Construction Advice</title><link>http://regexadvice.com/forums/68/ShowForum.aspx</link><description>&lt;P&gt;Find help building expressions to suit your needs. Consult the &lt;A href="http://regexlib.com"&gt;Regular Expression Library&lt;/A&gt; to find many pre-built expressions, and add your own once you've solved your construction problem in our forum.&lt;/P&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2.1 (Build: 60809.935)</generator><item><title>Re: Heading Text from Text File</title><link>http://regexadvice.com/forums/thread/82147.aspx</link><pubDate>Thu, 19 May 2011 03:17:00 GMT</pubDate><guid isPermaLink="false">d291b357-6366-4006-9008-4266c301325a:82147</guid><dc:creator>Aussie Susan</dc:creator><slash:comments>0</slash:comments><comments>http://regexadvice.com/forums/thread/82147.aspx</comments><wfw:commentRss>http://regexadvice.com/forums/commentrss.aspx?SectionID=68&amp;PostID=82147</wfw:commentRss><description>&lt;p&gt;You need to be clear in your own mind how you can specify which &amp;quot;experience&amp;quot; you want. Try sitting down with a pencil and paper and writing down the &amp;quot;rules&amp;quot; you would tell someone else as to how to pick out the right one. I&amp;#39;m guessing here but from your example text these rules might be:&lt;/p&gt;&lt;p&gt;- the work must start at the beginning of a line&lt;br /&gt;- the work bust be &amp;quot;experience&amp;quot; (ignoring the case of the letters)&lt;br /&gt;- there must be a colon immediately after the word&lt;/p&gt;&lt;p&gt;You then go through a number of examples of text and see if these rules always find just the words you are looking for - if not then go back and refine them until the do.&lt;/p&gt;&lt;p&gt;Assuming that the rules above are necessary and sufficient (that term means that each one must be there - necessary - and there are no others needed - sufficient) then you can create a pattern from them - say:&lt;/p&gt;&lt;p&gt;^experience:&lt;/p&gt;&lt;p&gt;with the &amp;quot;ignore case&amp;quot; and &amp;quot;multiline&amp;quot; options set (as you have done).&lt;/p&gt;&lt;p&gt;You will also not that this specifies ONLY the part that needs to be matched plus whatever else is around it to make sure that it is in the correct context - in this case that it should begin at start of the line and be followed by colon. In your pattern you include other things that are causing the regex engine to match more than you expect. For a start, the &amp;#39;[^a-zA-Z0-9]*&amp;#39; will let it match all sorts of special characters before the target word - this may be required but I can&amp;#39;t see why based only on the example text you have provided.&lt;/p&gt;&lt;p&gt;Also, the &amp;#39;.*$&amp;#39; the tell the regex engine to include everything from the end of the word to the end of the current line. (By the way, when i tried your pattern against this text, it actually matched to the end of &amp;quot;automation.&amp;quot; because that is how the &amp;quot;line&amp;quot; is presented - again I can only guess that&amp;nbsp; the line appeared to the regex engine to be split after &amp;quot;from&amp;quot; as you&amp;nbsp; have indicated).&lt;/p&gt;&lt;p&gt;A basic rule in writing regex patterns is that you don&amp;#39;t include something if you don&amp;#39;t want to use it in a match - in this case, if you don&amp;#39;t want the rest of the line then don&amp;#39;t include something in the pattern that will do just that. Of course, if you DO want the rest of the line, then that is fine but, again based on your example text and what you said you wanted to match, this is not the case here.&lt;/p&gt;&lt;p&gt;Susan &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Heading Text from Text File</title><link>http://regexadvice.com/forums/thread/82138.aspx</link><pubDate>Wed, 18 May 2011 06:49:42 GMT</pubDate><guid isPermaLink="false">d291b357-6366-4006-9008-4266c301325a:82138</guid><dc:creator>maha</dc:creator><slash:comments>0</slash:comments><comments>http://regexadvice.com/forums/thread/82138.aspx</comments><wfw:commentRss>http://regexadvice.com/forums/commentrss.aspx?SectionID=68&amp;PostID=82138</wfw:commentRss><description>Normal
  0
  
  
  
  
  false
  false
  false
  
  EN-US
  X-NONE
  X-NONE
  
   
   
   
   
   
   
   
   
   
   
   
  
  MicrosoftInternetExplorer4
  
   
   
   
   
   
   
   
   
   
   
   
  

 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 


 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-qformat:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin-top:0in;
	mso-para-margin-right:0in;
	mso-para-margin-bottom:10.0pt;
	mso-para-margin-left:0in;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman","serif";
	mso-bidi-font-family:"Courier New";}



&lt;p class="MsoNormal"&gt;Hai sir/friends&lt;br /&gt;
&lt;br /&gt;
Text File Content as Follows:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="background:none repeat scroll 0% 0% yellow;"&gt;Experience &lt;/span&gt;&lt;/b&gt;&lt;span style="background:none repeat scroll 0% 0% yellow;"&gt;performing various complex ETL
transformations in a variety of tools from&lt;/span&gt; Informatica to bare
PLSQL/TSQL. Good exposure to data interface design with disparate source
systems &amp;amp; automation.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="background:none repeat scroll 0% 0% red;"&gt;Experience:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
XXX Company Design, develop and maintain the analysis reports requested by the
marketing team and higher management for business forecasting and trend
analysis.&lt;br /&gt;
Analyze the transactional and analytic data and determine the individual
relationships and components for reporting.&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;b&gt;Explanation:&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
I need Header Text(Experience from Text File)&lt;br /&gt;
&lt;/p&gt;&lt;p class="MsoNormal"&gt;My current Regex Picks the yellow content But i need Experience from red
content&lt;/p&gt;

&lt;p class="MsoNormal"&gt;strPattern=&amp;rdquo;&lt;b&gt; &lt;/b&gt;&lt;span&gt;Experience&lt;b&gt;&amp;rdquo;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;Regex regex = new Regex(&amp;quot;^[^a-zA-Z0-9]*&amp;quot; +
Regex.Escape(strPattern) + &amp;quot;.*$&amp;quot;, &lt;/p&gt;

&lt;p class="MsoNormal"&gt;RegexOptions.IgnoreCase | RegexOptions.Multiline);&lt;/p&gt;

&lt;p class="MsoNormal"&gt;I need Heading Text only like Experi&lt;/p&gt;

&lt;p class="MsoNormal"&gt;Can you provide regex that match Red Content(Experience)?&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;Thank You in advance&lt;/p&gt;</description></item></channel></rss>