从<a href=""> with regular expression

时间:2016-12-08 11:40:04

标签: html regex jmeter

I work with JMeter and I need to get a link from the following <a href> tag:

<a href="/i/info/14259.html" class="ogrLink">Department page</a>

So I need a regular expression for getting this result: /i/info/14259.html

I have tried the following regex but not sure if it is correct:

i/info/[0-9]*.html

3 个答案:

答案 0 :(得分:1)

点击此处查看演示: https://regex101.com/r/eR2oH3/24 选定的数据将是1美元变量。

答案 1 :(得分:0)

由于您尝试从HTML中提取数据,因此最佳提取器为CSS/JQuery Extractor

CSS / JQuery表达式将简单如下:

  

a.ogrLink

属性

  

HREF

答案 2 :(得分:0)

下面是有效表达式:

&#13;
&#13;
val df = sc
     .parallelize(Seq(
        ("username1", "friend1"),
        ("username1", "friend2"),
        ("username2", "friend1"),
        ("username2", "friend3")))
     .toDF("username", "friend")

+---------+-------+
| username| friend|
+---------+-------+
|username1|friend1|
|username1|friend2|
|username2|friend1|
|username2|friend3|
+---------+-------+

val dfGRPD = df.map(Row => (Row(0), Row(1)))
     .groupByKey()
     .map{ case(username:String, groupOfFriends:Iterable[String]) => (username, groupOfFriends.mkString(","))}
     .toDF("username", "groupOfFriends")

+---------+---------------+
| username| groupOfFriends|
+---------+---------------+
|username1|friend2,friend1|
|username2|friend3,friend1|
+---------+---------------+
&#13;
&#13;
&#13;

Regular EXpression Extractor

引用名称是存储链接值

的变量