0

how would I convert this c# code to javascript to accomplish the same thing.

var s = styles.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

1 Answer 1

2

If styles is a string, it's as simple as:

styles.split(/[\r|\r\n]/);

var styles = 'body {font-size: 12px;}\n\
.someClass {color: red}';

document.querySelector('#result').textContent = '[' + (styles.split(/[\r|\r\n]/)) +']';
<pre id="result"></pre>

Sign up to request clarification or add additional context in comments.

3 Comments

I am trying to split the array at the comma. this didn't seem to work.
i am trying to change this: var s = style.split(/\r\n|\r/); return manager.executeQuery(breeze.EntityQuery.from("Orders").where("ID", "==", style));
The result of split is an Array. You can't split an Array, you can split a String. I can't say much on your usage of the splitted String style, but it seems wrong to use an Array as selector within a query. You can use elements from an Array though: s[element.position], e.g. s[0] returns the first element of array s.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.