Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var str="A,B,C,E,'F,G,bb',H,'I9,I8',J,K"
- A
- B
- C
- E
- F,G,bb
- H
- I9,I8
- J
- K
- > str.match(/('[^']+'|[^,]+)/g)
- ["A", "B", "C", "E", "'F,G,bb'", "H", "'I9,I8'", "J", "K"]
- var sample='this=that,
- sometext with quoted ",",
- for example,
- another 'with some, quoted text, and more',
- last,
- but "" "," "asdf,asdf" not "fff',' fff" the least';
- var it=sample.match(/([^"',]*(('[^']*')*||("[^"]*")*))+/gm);
- for (var x=0;x<it.length;x++) {
- var txt=$.trim(it[x]);
- if(txt.length)
- console.log(">"+txt+'<');
- }
- var input="A,B,C,E,'F,G,bb',H,'I9,I8',J,K";
- //Below pattern will not consider comma(,) between ''. So 'I9,I8' will be considered as single string and not spitted by comma(,).
- var pattern = ",(?=([^']*'[^']*')*[^']*$)";
- var output[] = input.split(pattern);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement