If I have this string like this
JavaScript
x
5
1
```
2
console.log()
3
```
4
Hello
5
or
JavaScript
1
5
1
Hello
2
```
3
console.log()
4
```
5
or
JavaScript
1
2
1
```console.log()``` Hello
2
or
JavaScript
1
2
1
Hello ```console.log()```
2
How do I get just the console.log() string?
———————————————- Edit ———————————————-
The regex I use is the combination between regex answered by @Himanshu Tanwar with the one suggested by @ASDFGerte
JavaScript
1
2
1
var code = s.match(/```([^`]*)```/)[1]
2
Advertisement
Answer
You can try doing it with regular expression
JavaScript
1
4
1
var s = "```console.log()```Hello";
2
3
var code = s.match(/```(.*)```/)[1]
4