.net - RegEx is not doing what I want -


i want retreive part of string, question if can correct string without touching matched string (substring or splitting), know easy split/substring want know if can improve regex job itself.

this string:

<h3 class="btl"><a href="http://post-hardcore.ru/music/2689-drifter-in-search-of-something-more-ep-2013.html">drifter - in search of more [ep] (2013)</a></h3> 

this get:

>drifter - in search of more [ep] (2013)</a>< 

this want get:

drifter - in search of more [ep] (2013) 

this regex:

dim regex_albumname new regex(">[^<].*<")  msgbox(regex_albumname.match(line).groups(0).tostring) 

i don't want this:

albumname = regex_albumname.match(line).groups(0).tostring.substring(1).replace("</a><", "") 

edit: note parentheses word "(2013)" may not in other strings need match.

your regex close. [^<] worked first character after > .* eat character until last <, because greedy. try this:

dim regex_albumname new regex(">([^<]+?)<")  msgbox(regex_albumname.match(line).groups(1).tostring) 

the ? tell regex match shortest possible string. in case think work without too.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -