RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
<!\[CDATA\[([^\]]*)\]\]>
Description
for getting cdata from and xml document. cdata returns in $1. it's not perfect as you can see from the non-matching examples. improvements needed - but this works for most scenario's.
Matches
<![CDATA[ gobbledy gook ]]> | <![CDATA[ gobbledy & more gook ]]>
Non-Matches
<![CDATA[ gobbledy ] gook ]]> | <![CDATA[ gobbledy ]] gook ]]>
Author Rating: The rating for this expression. dave krause
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Improvement suggestion
Name: Dima M.
Date: 5/13/2010 10:35:00 AM
Comment:
Hi, I know that this solution is with the help of using of lookaround and lookbehind, and it's more processor consuming, but it allows usage of all signs (including ']') in the CDATA content. (?<=<!\[CDATA\[)(.*?)(?=\]\]>)


Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials