【问题标题】:How to extract out the variable of special content format?How to extract out the variable of special content format?
【发布时间】:2022-12-27 22:07:41
【问题描述】:

How to extract out the variable of special content format?

I have below data:

# == 2.This is a ==
111111
222222
# == 2.This is a ==

# == 3.This is b ==
333333
# == 3.This is b ==

4
5

# == 2.This is a ==
66
77
8
# == 2.This is a ==

# == 4.This is c ==
9

# == 5.This is d ==
11
12
13
# == 5.This is d ==

10
# == 4.This is c ==

you see the special format # == {variable} == I want to extract out the variables.

but I don't know how to do with this, I have searched SO, get:
Extract variable from special string format Python
Regex Python : extracting special content

but neither is suitable for this situation.

【问题讨论】:

标签: javascript regex


【解决方案1】:

I'm not sure how to implement the solution in Javascript, but you can try something like this regex:

# == ([0-9.sa-zA-Z]+)

See the solution in action here: https://regex101.com/r/OCLO1k/1

【讨论】:

  • there is # == {var} == how to match the suffix?
猜你喜欢
  • 2022-12-26
  • 2022-12-02
  • 2022-12-01
  • 2022-12-02
  • 2022-12-28
  • 2022-12-19
  • 2022-12-27
  • 2022-12-01
  • 2022-12-01
相关资源
最近更新 更多