I have the following string:    var str = 'd:\\projects\\my_project\\dist\\js\\example.js'   I want to split the string into an array as follows:  ['d:', 'projects', 'my_project', 'dist', 'js', 'example', 'js']   How can do this with str.split(regex)? What is the proper regex I need?  Already tried str.split('(\.|\\)') and str.split('\.|\\') (i.e. w/out parenthesis)  Both '\.' and '\\' work when individually passed, but not combined.  Please help me regex masters!
13318
How do I split a string with multiple separators in JavaScript? I'm trying to split on both commas and spaces, but AFAIK JavaScript's split() function only supports one separator.
104616
I already managed to split the CSV file using this regex: "/,(?=(?:[^\"]\"[^\"]\")(?![^\"]\"))/"  But I ended up with an array of strings that contain the opening and ending double quotes. Now I need a regex that would strip those strings of the delimiter double quotes.  As far as I know the CSV format can encapsulate strings in double quotes, and all the double quotes that are already a part of the string are doubled. For example:  My "other" cat     becomes  "My ""other"" cat"  What I basically need is a regex that will replace all sequences of N doublequotes with a sequence of (N/2 - rounded down) double quotes.  Or is there a better way ? Thanks in advance.
95331
How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#?  Sorry if it's a stupid question, I'm new to Regex.  I know to do it using plan String.Replace, like:  myStr.Replace("\n", "\r\n"); myStr.Replace("\r\r\n", "\r\n");   However, this is inelegant, and would destroy any "\r+\r\n" already in the text (although they are not likely to exist).
4307
How can I replace multiple spaces in a string with only one space in C#?  Example:  1 2 3  4    5   would be:  1 2 3 4 5
1821
I have a one-dimensional array of strings in JavaScript that I'd like to turn into a comma-separated list. Is there a simple way in garden-variety JavaScript (or jQuery) to turn that into a comma-separated list? (I know how to iterate through the array and build the string myself by concatenation if that's the only way.)
14412
I have created a function wherein I split a string from the csv filecsvAsString.split('\n') . It is working when the string is not so big. But when I try to split a very large string, an error will occur      regex too complicated   what I want to do is to catch if an error occur during the split process. How will I do it ? I've tried to use try and catch but the problem still occur. Is there any other possible solution?
4663
This will surely be an easy one but it is really bugging me.   I have a script that reads in a webpage and uses  to parse it. From the soup I extract all the links as my final goal is to print out the link.contents.  All of the text that I am parsing is ASCII. I know that Python treats strings as unicode, and I am sure this is very handy, just of no use in my wee script.   Every time I go to print out a variable that holds 'String' I get [u'String'] printed to the screen. Is there a simple way of getting this back into just ascii or should I write a regex to strip it?
22511
I want to use input from a user as a regex pattern for a search over some text.  It works, but how I can handle cases where user puts characters that have meaning in regex? For example, the user wants to search for Word (s): regex engine will take the (s) as a group.  I want it to treat it like a string &quot;(s)&quot; .  I can run replace on user input and replace the ( with \( and the ) with \) but the problem is I will need to do replace for every possible regex symbol. Do you know some better way ?
3211
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM J0000010: Project name: E:\foo.pf J0000011: Job name: MBiek Direct Mail Test J0000020: Document 1 - Completed successfully  I'm trying to extract pieces from it using regex. In this case, I want to grab everything after Project Name up to the part where it says J0000011: (the 11 is going to be a different number every time). Here's the regex I've been playing with: Project name:\s+(.*)\s+J[0-9]{7}:  The problem is that it doesn't stop until it hits the J0000020: at the end. How do I make the regex stop at the first occurrence of J[0-9]{7}?
33856
I want to display all the characters in a file between strings "xxx" and "yyy" (the quotes are not part of the delimiters). How can I do that ? For example, if i have input "Hello world xxx this is a file yyy", the output should be " this is a file "
97749
C#,  a String's Split() method, how can I put the resulting string[] into an ArrayList or Stack?
51028
I'm splitting a string by three different characters but I want the output to include the characters I split by. Is there any easy way to do this?
80715
In javascript, what is the best way to parse an INT from a string which starts with a letter (such as "test[123]")?  I need something that will work for the example below.  My JS:  $(document).ready(function() {      $(':input').change( function() {         id = parseInt($(this).attr("id"));  //fails for the data below         alert(id);     }); }   My generated HTML:  &lt;select id="attribute[123]"&gt; &lt;!-- various options --&gt; &lt;/select&gt; &lt;select id="attribute[456]"&gt; &lt;!-- various options --&gt; &lt;/select&gt;   Thank you!
23579
It's probably beginner question but I'm going through documentation for longer time already and I can't find any solution. I thought I could use implode for each dimension and then put those strings back together with str_split to make new simple array. However I never know if the join pattern isn't also in values and so after doing str_split my original values could break.  Is there something like combine($array1, $array2) for arrays inside of multi-dimensional array?
6354
It seems like every question on stackoverflow where the asker is using regex to grab some information from HTML will inevitably have an "answer" that says not to use regex to parse HTML.  Why not? I'm aware that there are quote-unquote "real" HTML parsers out there like , and I'm sure they're powerful and useful, but if you're just doing something simple, quick, or dirty, then why bother using something so complicated when a few regex statements will work just fine?  Moreover, is there just something fundamental that I don't understand about regex that makes them a bad choice for parsing in general?
262
I don't really understand regular expressions.  Can you explain them to me in an easy-to-follow manner?  If there are any online tools or books, could you also link to them?
6296
What regex pattern would need I to pass to  java.lang.String.split()  to split a String into an Array of substrings using all whitespace characters (' ', '\t', '\n', etc.) as delimiters?