Search Results

Search found 36065 results on 1443 pages for 'string manipulation'.

Page 20/1443 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • Attempting to extract a pattern within a string

    - by Brian
    I'm attempting to extract a given pattern within a text file, however, the results are not 100% what I want. Here's my code: import java.util.regex.Matcher; import java.util.regex.Pattern; public class ParseText1 { public static void main(String[] args) { String content = "<p>Yada yada yada <code> foo ddd</code>yada yada ...\n" + "more here <2004-08-24> bar<Bob Joe> etc etc\n" + "more here again <2004-09-24> bar<Bob Joe> <Fred Kej> etc etc\n" + "more here again <2004-08-24> bar<Bob Joe><Fred Kej> etc etc\n" + "and still more <2004-08-21><2004-08-21> baz <John Doe> and now <code>the end</code> </p>\n"; Pattern p = Pattern .compile("<[1234567890]{4}-[1234567890]{2}-[1234567890]{2}>.*?<[^%0-9/]*>", Pattern.MULTILINE); Matcher m = p.matcher(content); // print all the matches that we find while (m.find()) { System.out.println(m.group()); } } } The output I'm getting is: <2004-08-24> bar<Bob Joe> <2004-09-24> bar<Bob Joe> <Fred Kej> <2004-08-24> bar<Bob Joe><Fred Kej> <2004-08-21><2004-08-21> baz <John Doe> and now <code> The output I want is: <2004-08-24> bar<Bob Joe> <2004-08-24> bar<Bob Joe> <2004-08-24> bar<Bob Joe> <2004-08-21> baz <John Doe> In short, the sequence of "date", "text (or blank)", and "name" must be extracted. Everything else should be avoided. For example the tag "Fred Kej" did not have any "date" tag before it, therefore, it should be flagged as invalid. Also, as a side question, is there a way to store or track the text snippets that were skipped/rejected as were the valid texts. Thanks, Brian

    Read the article

  • String chunking algorithm with natural language context

    - by Chris Ballance
    I have a arbitrarily large string of text from the user that needs to be split into 10k chunks (potentially adjustable value) and sent off to another system for processing. Chunks cannot be longer than 10k (or other arbitrary value) Text should be broken with natural language context in mind split on punctuation when possible split on spaces if no punction exists break a word as a last resort I'm trying not to re-invent the wheel with this, any suggestions before I roll this from scratch? Using C#.

    Read the article

  • Perl String operations

    - by imerez
    I have a string with the following e.g. $workingFile = '/var/tmp/A/B/filename.log.timestamps.etc'; And two strings representing a dirs e.g. $dir = '/var/tmp'; $newDir = '/users/asdf'; I'd like to get the following: '/users/asdf/A/B/filename.log.timestamps.etc' However my Perl isnt up to much .. any pointers ? Thanks W

    Read the article

  • What's a good matrix manipulation library available for C ?

    - by banister
    Hi, I am doing a lot of image processing in C and I need a good, reasonably lightweight, and above all FAST matrix manipulation library. I am mostly focussing on affine transformations and matrix inversions, so i do not need anything too sophisticated or bloated. Primarily I would like something that is very fast (using SSE perhaps?), with a clean API and (hopefully) prepackaged by many of the unix package management systems. Note this is for C not for C++. Thanks :)

    Read the article

  • Format string, integer with leading zeros

    - by ghiboz
    Hi all! I Use this code: NSString* strName = [NSString stringWithFormat:@"img_00%d.jpg", pp]; and works fine, but if pp took the value of 10 for example I wish have img_010.jpg as result, and not img_0010.jpg... how can I format the string?? thanks

    Read the article

  • how to split a string by another string ?

    - by Nikhil Vaghela
    I have a string in following format "TestString 1 <^ TestString 2 <^ Test String3 Which i want to split by "<^" string. Using following statement it gives the output i want "TestString 1 <^> TestString 2 <^> Test String3" .Split("<^>".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) But if my string contains "<" , "" or "^" anywhere in the text then above split statement will consider that as well Any idea how to split only for "<^" string ?

    Read the article

  • get city, state or zip from a string in python

    - by Joe
    I'd like to be able to parse out the city, state or zip from a string in python. So, if I entered Boulder, Co 80303 Boulder, Colorado Boulder, Co 80303 ... any variation of these it would return the city, state or zip. This is all going to be user inputted data and inputted in one text field.

    Read the article

  • Coldfusion: insert new line into string

    - by dmr
    I would like to insert a line break into the first space between words in a string variable. Here is my code so far: <cfset myPosition = find(" ", #myVar#)> <cfset lineBreak = Chr(13)&Chr(10)> <cfset myVar = insert(#lineBreak#, #myVar#, #myPosition#)> What am I doing wrong?

    Read the article

  • Delete all characters in a multline string upto a given pattern

    - by biffabacon
    Using Python I need to delete all charaters in a multiline string up to the first occurrence of a given pattern. In Perl this can be done using regular expressions with something like: #remove all chars up to first occurrence of cat or dog or rat $pattern = 'cat|dog|rat' $pagetext =~ s/(.*)($pattern)/$2/xms; What's the best way to do it in Python?

    Read the article

  • Split string with zsh as in Python

    - by Olivier
    In python: s = '1::3' a = s.split(':') print a[0] # '1' good print a[1] # '' good print a[2] # '3' good How can I achieve the same effect with zsh? The following attempt fails: s="1::3" a=(${(s/:/)s}) echo $a[1] # 1 echo $a[2] # 3 ?? I want an empty string, as in Python

    Read the article

  • Delete all characters in a multline string up to a given pattern

    - by biffabacon
    Using Python I need to delete all charaters in a multiline string up to the first occurrence of a given pattern. In Perl this can be done using regular expressions with something like: #remove all chars up to first occurrence of cat or dog or rat $pattern = 'cat|dog|rat' $pagetext =~ s/(.*?)($pattern)/$2/xms; What's the best way to do it in Python?

    Read the article

  • Print one word from a string in python

    - by Shai
    Hi, How can i print only certain words from a string in python ? lets say i want to print only the 3rd word (which is a number) and the 10th one while the text length may be different each time mystring = "You have 15 new messages and the size is 32000" thanks.

    Read the article

  • ruby - find and replace in a string for commonly used street suffix

    - by go minimal
    The post office actually publishes a list of commonly used street suffixes in addresses: http://www.usps.com/ncsc/lookups/abbr_suffix.txt I want to take this list and make a ruby function that takes a string, takes the last word ("183 main strt".split[' '].last) and if it matches any of the commonly used street suffixes ("strt"), replace it with the official Postal Service Standard Suffix ("st"). Is there a better way to approach this than a massive str.sub.sub.sub.sub.sub?

    Read the article

  • How to evaluate the string in ruby if the string contains ruby command?

    - by Arun
    In my case, I was storing the sql query in my database as text. I am showing you one record which is present in my database Query.all :id => 1, :sql => "select * from user where id = #{params[:id]}" str = Query.first Now 'str' has value "select * from user where id = #{params[:id]}" Here, I want to parsed the string like If my params[:id] is 1 then "select * from user where id = 1" I used eval(str). Is this correct?

    Read the article

  • C#: Loop through substring patterns in a string

    - by ilann
    my pattern is the following: {(code)} where code is a number (up to 6 digits), or 2 letter followed by a number. For example: {(45367)} {(265367)} {(EF127012)} I want to find all occurrences in a long string, I can't just use pure regex , because I need to preform some action when i find a match (like logging the position and the type of the match).

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >