我有如下格式的字符串们:
我想要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)
10 回答11.3k 阅读
5 回答4.9k 阅读✓ 已解决
4 回答3.2k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
3 回答2.4k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决