Results 1 to 4 of 4
-
16th Jun 2010, 10:31 PM #1OPლ(ಠ益ಠლ)Website's:
extremecoderz.com[c#] Get String In between strings
This static string will obtain a string in between 2 strings.
For example. I have the string:
Code:<a href="myfile.php">foo-bar</a>
Code:result = GetStringInbetween("\">", "</a>", sourceFile, false, false); string myString = result[0];
Code:string[] result; public static string[] GetStringInBetween(string strBegin, string strEnd, string strSource, bool includeBegin, bool includeEnd) { string[] result = { "", "" }; int iIndexOfBegin = strSource.IndexOf(strBegin); if (iIndexOfBegin != -1) { if (includeBegin) { iIndexOfBegin -= strBegin.Length; } strSource = strSource.Substring(iIndexOfBegin + strBegin.Length); int iEnd = strSource.IndexOf(strEnd); if (iEnd != -1) { if (includeEnd) { iEnd += strEnd.Length; } result[0] = strSource.Substring(0, iEnd); if (iEnd + strEnd.Length < strSource.Length) { result[1] = strSource.Substring(iEnd + strEnd.Length); } } } else { result[1] = strSource; } return result; }
jayfella Reviewed by jayfella on . [c#] Get String In between strings This static string will obtain a string in between 2 strings. For example. I have the string: <a href="myfile.php">foo-bar</a> If i wanted to get the name of the link (foo-bar): result = GetStringInbetween("\">", "</a>", sourceFile, false, false); Rating: 5
-
16th Jun 2010, 10:47 PM #2MemberWebsite's:
litewarez.net litewarez.com triniwarez.comWould you be able to do a regex or a XML version of this
What if we had <a href="myfile.php"><span class="foo">bar</span></a>
would return bar</span> rightJoin Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
16th Jun 2010, 10:48 PM #3OPლ(ಠ益ಠლ)Website's:
extremecoderz.comyes thats exactly what it would return in the example you gave yes.
The XML parser i posted previously does what you need for XML. It gets/sets node values.
-
16th Jun 2010, 11:23 PM #4Respected Developer
Never parse markup with regex's, ever. Jay's method is how it should be done. To fully parse XML you'd do that sort of magic with the help of a FSM.
Edit:
My bad . Actually you're right since this isn't meant to parse. But still if it can be done with string functions it should because they are a hell of a lot faster.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
C++ string search help needed
By googleplus in forum Web Development AreaReplies: 0Last Post: 12th May 2012, 04:42 PM -
php string - heredoc syntax
By desiboy in forum Web Development AreaReplies: 3Last Post: 16th Nov 2010, 05:15 PM -
Extracting data from a string
By pankaj in forum Web Development AreaReplies: 38Last Post: 6th Jul 2010, 01:38 PM -
Review Warez Strings!
By InnoX in forum Site ReviewsReplies: 4Last Post: 18th Jun 2010, 10:18 PM -
[Shared] [Gigapulse] Free Hosting(no strings attached)... Just try Us and you'll love us...
By ragavbpl1 in forum ArchiveReplies: 13Last Post: 28th Oct 2009, 05:06 AM
themaCreator - create posts from...
Version 3.24 released. Open older version (or...