Reputation: 89
/index.php?option=com_phocagallery&view=category&id=54:jubilaci-2014&Itemid=57"><img src="/./images/phocagallery/jubilaci2014/thumbs/phoca_thumb_m_zbiorwka zbowice kopiowanie.jpg" alt="Jubilaci 2014" style="border:0" />
/index.php?option=com_phocagallery&view=category&id=52:obszar-funkcjonalny-kluczbork-namysw-olesno&Itemid=57"><img src="/./images/phocagallery/obszarfunkcjonalny/thumbs/phoca_thumb_m_dsc_1005retusz kopiowanie.jpg" alt="Obszar Funkcjonalny Kluczbork-Namysłów-Olesno" style="border:0" />
/index.php?option=com_phocagallery&view=category&id=39:szkolenie-z-obrony-cywilnej&Itemid=57" class="category">Szkolenie z Obrony Cywilnej
I get such list, and i want to get from this only link, like this:
/index.php?option=com_phocagallery&view=category&id=26:jubilaci-2011&Itemid=57
How can I do it using Regex? Maybe how to get everything before character, in my case it would be:
"
I have tried st like this:
.*">
But it doesn't work as i want to.
Upvotes: 1
Views: 40
Reputation: 172270
Here's a solution without lookahead:
^[^"]+
^
: Start of the line,[^"]
: all characters that are not double quotes,+
: at least one those characters (greedy = as many as possible).However, since you have tagged your question as C#, you could just split on "
and take the first part -- no regular expression required:
var result = myString.Split('"')[0];
Upvotes: 2
Reputation: 174706
You need to use a positive lookahead assertion.
@"(?m)^.*?(?="")"
It matches all the characters from the start upto the first "
double quotes.
Upvotes: 1