The ultimate tool for matching 'strings'

author
By Team Srijan Aug 26, 2008

As per client project requirement, I had to do some string matching ...... and behold, Ahm... that too keeping the pattern intact.

So googled through the few pages, then suddenly came with an idea to give a try to regular expression [regexp]. Now who is going to help me out.

Bingo!! take help from PJ [Our Sys Admin]. Hey PJ can you help me out with the problem. Sure , he forwarded with a link and page 192 of the OReilly book for perl. Hmmm... now i got some idea.

Tried to combine both googled page and reference from the book and that resolved my worries. 

Challange: <ab-cd>Some text</ab-cd> <de-fg> Some text</de-fg> ..... Take out all the tags and keep the text between the tags in order. 

Solution: [php] preg_match_all

$pattern = "/(<([\w\-]+)[^>]*>)(.*)(<\/\\2>)/"; preg_match_all($pattern,$content,$out, PREG_PATTERN_ORDER); $out[2] will display an array of matched tags $out[3] will display an array of text with the matched tags.

Shared Success

Building a Consent Management Platform for Compliance and Protection of PII Data
How Launching a Dynamic eCommerce Platform Streamlined Procurement for the Dental Support Organizations
Building Enterprise Chatbots With Amazon Lex
Case Study on India Today Network: B2B Classifieds Portal

Let’s start our conversation

  • Business Inquiry
  • Career
  • Others

Business Inquiry

Career

Others