简体   繁体   中英

Getting String between two Strings with regular Expressions

I have a long String:

1;#Subject:SW|
vti_parserversion:SR|14.0.0.4762
vti_folderitemcount:IR|0
_Category:SW|
vti_author:SR|SHAREPOINT\\system
_dlc_DocIdItemGuid:SW|8435986b-4ff2-4e03-9879-d15568d88f0b
vti_approvallevel:SR|
vti_categories:VW|
vti_foldersubfolderitemcount:IR|0
vti_modifiedby:SR|SHAREPOINT\\system
vti_assignedto:SR|
Keywords:SW|
_Status:SW|
vti_cachedcustomprops:VX|vti_approvallevel vti_categories Subject vti_assignedto Keywords _Status vti_title _Author _Category _dlc_DocId _Comments _dlc_DocIdUrl _dlc_DocIdItemGuid
ContentTypeId:SW|0x01010013CD7B577B3AC84B8467BC0F2B82B30D
_dlc_DocId:SW|5VQNHKQHD5Z4-9-1
vti_cachedtitle:SR|SharePoint 2010 Deployment Guide
vti_title:SR|SharePoint 2010 Deployment Guide
_Author:SW|
_dlc_DocIdUrl:SW|http://blub.com/_layouts/DocIdRedir.aspx?ID=5VQNHKQHD5Z4-9-2, 5VQNHKQHD5Z4-9-1
_Comments:SW|


And I want to parse the DocIdUrl (the String between "_dlc_DocIdUrl:SW|" and ",") , I am using RegexKitLite with: String stringByMatching:regExP

This is my first RegExpression: NSString* regExp = @"(?=\\_dlc_DocIdUrl:SW|)(.*?)(?=\\,)";

But it gives me: _dlc_DocIdUrl:SW|http://blub.com/_layouts/DocIdRedir.aspx?ID=5VQNHKQHD5Z4-9-2

I only want the URL, how can i solve that?

I am confused!

Here is the regex solving your problem:

_dlc_DocIdUrl:SW\|(?<value>[^,]*),+

You will find the requested URL in the group named "value"

(?<=_dlc_DocIdUrl:SW\|)[^,]*(?=,)

这可以直接为您提供所需的信息,而无需分组。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM