I need to split some sentences into words.   For example:  Upper sentence. Lower sentence. And some text.   I do it by:   String[] words = text.split("(\\s+|[^.]+$)");   But the output I get is:  Upper, sentence.Lower, sentence., And, some, text.   And it should be like:  Upper, sentence., Lower, sentence., And, some, text.   Notice that I need to preserve all the characters (.,-?! etc.)
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?
79970
I would like to use the .Net Regex.Split method to split this input string into an array. It must split on whitespace unless it is enclosed in a quote.  Input:  Here is "my string"&nbsp;&nbsp;&nbsp;&nbsp;it has "six&nbsp;&nbsp;matches"  Expected output:   Here is my string it has six&nbsp;&nbsp;matches   What pattern do I need? Also do I need to specify any RegexOptions?
92395
I want to split a command line like string in single string parameters. How look the regular expression for it. The problem are that the parameters can be quoted. For example like:  "param 1" param2 "param 3"  should result in:  param 1, param2, param 3
92412
I have an array of 1000 or so entries, with examples below:  wickedweather liquidweather driveourtrucks gocompact slimprojector   I would like to be able to split these into their respective words, as:  wicked weather liquid weather drive our trucks go compact slim projector   I was hoping a regular expression my do the trick.  But, since there is no boundary to stop on, nor is there any sort of capitalization that I could possibly key on, I am thinking, that some sort of reference to a dictionary might be necessary?    I suppose it could be done by hand, but why - when it can be done with code! =)  But this has stumped me.  Any ideas?
6954
I'm trying to split text in a JTextArea using a regex to split the String by \n However, this does not work and I also tried by \r\n|\r|n and many other combination of regexes. Code:  public void insertUpdate(DocumentEvent e) {     String split[], docStr = null;     Document textAreaDoc = (Document)e.getDocument();      try {         docStr = textAreaDoc.getText(textAreaDoc.getStartPosition().getOffset(), textAreaDoc.getEndPosition().getOffset());     } catch (BadLocationException e1) {         // TODO Auto-generated catch block         e1.printStackTrace();     }      split = docStr.split("\\n"); }
39746
I have a java string, which has a variable length.   I need to put the piece "&lt;br&gt;" into the string, say each 10 characters.   For example this is my string:  `this is my string which I need to modify...I love stackoverlow:)`   How can I obtain this string?:  `this is my&lt;br&gt; string wh&lt;br&gt;ich I nee&lt;br&gt;d to modif&lt;br&gt;y...I love&lt;br&gt; stackover&lt;br&gt;flow:)`   Thanks
70523
Does anyone know of a Java library that handles finding sentence boundaries? I'm thinking that it would be a smart StringTokenizer implementation that knows about all of the sentence terminators that languages can use.  Here's my experience with BreakIterator:  Using the example : I have the following Japanese:  今日はパソコンを買った。高性能のマックは早い！とても快適です。   In ascii, it looks like this:  \ufeff\u4eca\u65e5\u306f\u30d1\u30bd\u30b3\u30f3\u3092\u8cb7\u3063\u305f\u3002\u9ad8\u6027\u80fd\u306e\u30de\u30c3\u30af\u306f\u65e9\u3044\uff01\u3068\u3066\u3082\u5feb\u9069\u3067\u3059\u3002   Here's the part of that sample that I changed:   static void sentenceExamples() {    Locale currentLocale = new Locale ("ja","JP");   BreakIterator sentenceIterator =       BreakIterator.getSentenceInstance(currentLocale);   String someText = "今日はパソコンを買った。高性能のマックは早い！とても快適です。";   When I look at the Boundary indices, I see this:  0|13|24|32   But those indices don't correspond to any sentence terminators.
6643
I am doing something where I realised I wanted to count how many /s I could find in a string, and then it struck me, that there were several ways to do it, but couldn't decide on what the best (or easiest) was.  At the moment I'm going with something like:  string source = "/once/upon/a/time/"; int count = source.Length - source.Replace("/", "").Length;   But I don't like it at all, any takers?  I don't really want to dig out RegEx for this, do I?  I know my string is going to have the term I'm searching for, so you can assume that...  Of course for strings where length > 1,  string haystack = "/once/upon/a/time"; string needle = "/"; int needleCount = ( haystack.Length - haystack.Replace(needle,"").Length ) / needle.Length;
63506
This is a part of my .  I have the below logic to split a string value from a column in table tblProjects as below:  SELECT  @Docs = Documents FROM tblProjects WHERE ID = @ID  SET @Docs = @Docs + '$' SET @pos = 0 SET @len = 0  WHILE CHARINDEX('$', @Docs, @pos + 1)&gt;0 BEGIN   SET @len = CHARINDEX('$', @Docs, @pos + 1) - @pos   SET @value = SUBSTRING(@Docs, @pos, @len)    IF CHARINDEX('|', @value) &gt;0   BEGIN     SELECT  @type = SUBSTRING(@value, 1, CHARINDEX('|', @value) - 1),             @name = SUBSTRING(@value, CHARINDEX('|', @value) + 1, 200)     INSERT INTO tblDocuments VALUES(@ID, @value, @type, @name)   END       SET @pos = CHARINDEX('$', @Docs, @pos + @len) +1 END   A sample input would be   insert into tblProjects(ID, Documents)  values('P_1', 'gdgfg|jkkgk$bkgkkj|kjgkgk$vjffj|Khkgjhg$jkgkvghv|kbkghhkgk');   I need to split the Documents string and insert the values into a separate table. Values delimited by | should go into separate columns of the same row, whereas values for a particular row are delimited by $.   Is there a single query method to complete this operation, for all rows in the table, in the minimum possible time?
1707
I have several strings in the rough form:  [some text] [some number] [some more text]   I want to extract the text in [some number] using the Java Regex classes.  I know roughly what regular expression I want to use (though all suggestions are welcome). What I'm really interested in are the Java calls to take the regex string and use it on the source data to produce the value of [some number].  EDIT: I should add that I'm only interested in a single [some number] (basically, the first instance). The source strings are short and I'm not going to be looking for multiple occurrences of [some number].
25091
I've found I can make punctuation happen by saying "comma", or "period", but I can't find the word for new line.  I tried "paragraph", and "line break", but it just prints those words.
87499
Can someone provide a regular expression for parsing name/value pairs from a string?  The pairs are separated by commas, and the value can optionally be enclosed in quotes.  For example:  AssemblyName=foo.dll,ClassName="SomeClass",Parameters="Some,Parameters"
57185
I want to split a character string n by n. I know how to do that 1 by 1 :  \documentclass{article} \makeatletter  \def\s@plit&lt;#1#2&gt;{%   \ifx\empty#2%     #1%   \else     #1,\s@plit&lt;#2&gt;%   \fi}  \def\Split#1#2{\s@plit&lt;#2\empty&gt;} \makeatother  \begin{document} \Split{1}{123456789} \end{document}   It gives : 1,2,3,4,5,6,7,8,9  But I also want 1,23,45,67,89 or 123,456,789 ... depending from the first parameter.  EDIT  Work straight and reverse, even with foreach.        \documentclass{article}     \usepackage{tikz,xparse,xstring}  \DeclareDocumentCommand{\split}{smmo}{%     \xdef\Entree{#3}%     \let\Sortie\empty%     \IfBooleanTF #1     {% sans étoile         \loop         \StrRight{\Entree}{#2}[\tmp]%         \edef\Sortie{\Sortie,\tmp}%         \StrGobbleRight{\Entree}{#2}[\Entree]%         \unless\ifx\Entree\empty         \repeat         \StrGobbleLeft{\Sortie}{1}[\Sortie]%     }     {% avec étoile dans l'ordre inverse         \loop         \StrRight{\Entree}{#2}[\tmp]%         \edef\Sortie{\tmp,\Sortie}%         \StrGobbleRight{\Entree}{#2}[\Entree]%         \unless\ifx\Entree\empty         \repeat         \StrGobbleRight{\Sortie}{1}[\Sortie]%     }     \IfNoValueTF{#4}{\Sortie}{\edef#4{\Sortie}}     }  \begin{document} \split{2}{6513782}  \split*{2}{6513782}  \split*{2}{6513782}[\bob]  \foreach \x in \bob {[\x] }  \end{document}
4322
I have a long line of code that I want to break up among multiple lines. What do I use and what is the syntax?  For example, adding a bunch of strings,  e = 'a' + 'b' + 'c' + 'd'   and have it in two lines like this:  e = 'a' + 'b' +     'c' + 'd'
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 "
113626
I am looking for a way to extract a variable length substring from a string.  My cells will look something like:  ABC - DEF ABCDE - DEF ABCD - ABC   I want to split the string at the - character, so the cells will become:  ABC ABCDE ABCD   This should be done with a formula and not VBScript.  I am using Excel 2010  EDIT  I found that the dataset doesn't always contain the - character, meaning there should be no change.
106755
ok so basically I am asking the question of their name I want this to be one input rather than Forename and Surname.  Now is there any way of splitting this name? and taking just the last word from the "Sentence" e.g.  name = "Thomas Winter" print name.split()    and what would be output is just "Winter"