Given a string containing 'blabla <a href="address">text</a> blabla'
, I want to extract 'text'
from it.
(给定一个包含'blabla <a href="address">text</a> blabla'
的字符串,我想从中提取'text'
。)
regexp doc suggests '<(\w+).*>.*</\1>'
expression, but it extracts the whole <a> ... </a>
thing.
(regexp doc建议使用'<(\w+).*>.*</\1>'
表达式,但它将提取整个<a> ... </a>
内容。)
Of course I can continue using strfind
like this:
(当然,我可以像这样继续使用strfind
:)
line = 'blabla <a href="address">text</a> blabla';
atag = regexp(line,'<(w+).*>.*</1>','match', 'once');
from = strfind(atag, '>');
to = strfind(atag, '<');
text = atag((from(1)+1):(to(2)-1))
, but, can I use another expression to find text
at once?
(,但是,我可以使用其他表达式一次查找text
吗?)
ask by saastn translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…