0

I have sentences like

Cash is king. The day you prepared the accounting plan, I was sure that you will draft the accounting standards carefully and our accounts will not required to be window dressed. Sir you write the narration.

and I want to split this sentence with ? and .

for that I have used

var words= 'Cash is king. The day you prepared the accounting plan, I was sure that you will draft the accounting standards carefully and our accounts will not be required to be window dressed. Sir you write the narration.';
var split = words.split(".");

console.log(split);

it is working but I want to split the sentence with ? and . both at the same time. How can I do that?

can anybody help me with this

freedomn-m
  • 27,664
  • 8
  • 35
  • 57

1 Answers1

0

You can split on both ? and . at the same time using the regular expression format of .split(), ie:

words.split(/[?.]/)

Example snippet:

var test = "abc?def.ghi";
var parts = test.split(/[?.]/)
console.log(parts)
freedomn-m
  • 27,664
  • 8
  • 35
  • 57