character - Javascript comparing line ending values -


i trying compare line ending values saved in db, '\r\n', '\r' , '\n'. possible? or there way. doesn't work...

if (value === "\r\n") {     return "carriagereturnnewline"; } if (value === "\r") {     return "carriagereturn"; } if (value === "\n") {     return "newline"; } 

one way string match() method , regular expression:

if (value.match(/\r\n/)) {     return "carriagereturnnewline"; } if (value.match(/\r/)) {     return "carriagereturn"; } if (value.match(/\n/)) {     return "newline"; } 

for reference: https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/match


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -