我有如下格式的字符串们:
我想要trim掉左边的# ==
和右边的==
,
# == 3.This is b ==
# == 2.This is == a ==
# == 4.This is === c ==
# == 5.This is d ==
想要得到:
3.This is b
2.This is == a
4.This is === c
5.This is d
请问是否有方法可以得到呢?
我有如下格式的字符串们:
我想要trim掉左边的# ==
和右边的==
,
# == 3.This is b ==
# == 2.This is == a ==
# == 4.This is === c ==
# == 5.This is d ==
想要得到:
3.This is b
2.This is == a
4.This is === c
5.This is d
请问是否有方法可以得到呢?
`# == 3.This is b ==
# == 2.This is == a ==
# == 4.This is === c ==
# == 5.This is d ==`.replace(/^# == |==$/gm, '')
let str = '# == 3.This is b =='
let newArr = str.split(' ').slice(2, -1).join(' ')
console.log(newArr)
8 回答5.8k 阅读✓ 已解决
9 回答9.2k 阅读
6 回答4.8k 阅读✓ 已解决
5 回答3.5k 阅读✓ 已解决
4 回答7.9k 阅读✓ 已解决
7 回答9.8k 阅读
5 回答7.1k 阅读✓ 已解决