Search Results

Search found 999 results on 40 pages for 'substring'.

Page 5/40 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • regex substring C#

    - by sharma
    Hi, I need help to figure the regex expression I have string = "STATE changed from [Fixed] to [Closed], CLOSED DATE added [Fri Jan 14 09:32:19 MST 2011], NOTES changed from [CLOSED[]<br />] to [TEST CLOSED <br />]" I need to grab NOTES changed from [CLOSED[]<br />] to [TEST CLOSED <br />] and take values CLOSED[] and TEST CLOSED in two string variables. So far I got to: Regex NotesChanged = new Regex(@"NOTES changed from \[(\w*|\W*)\] to \[([\w-|\W-]*)\]"); which matches only if "NOTES changed from" started at the beginning and has no '[]' within '[ ]', but I have "[CLOSED[]]" and also no "". Any ideas on what to change in regex. Thanks, Sharma

    Read the article

  • How can I take the first 100 characters of html content ( without stripping the TAGS! )

    - by Atomiton
    There are lots of questions on how to strip html tags, but not many on functions/methods to close them. Here's the situation. I have a 500 character Message summary ( which includes html tags ), but I only want the first 100 characters. Problem is if I truncate the message, it could be in the middle of an html tag... which messes up stuff. Assuming the html is something like this: <div class="bd">"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <br/> <br/>Some Dates: April 30 - May 2, 2010 <br/> <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. <em>Duis aute irure dolor in reprehenderit</em> in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. <br/> </p> For more information about Lorem Ipsum doemdloe, visit: <br/> <a href="http://www.somesite.com" title="Some Conference">Some text link</a><br/> </div> How would I take the first ~100 characters or so? ( Although, ideally that would be the first approximately 100 characters of "CONTENT" ( in between the html tags ) I'm assuming the best way to do this would be a recursive algorithm that keeps track of the html tags and appends any tags that would be truncated, but that may not be the best approach. My first thoughts are using recursion to count nested tags, and when we reach 100 characters, look for the next "<" and then use recursion to write the closing html tags needed from there. The reason for doing this is to make a short summary of existing articles without requiring the user to go back and provide summaries for all the articles. I want to keep the html formatting, if possible. NOTE: Please ignore that the html isn't totally semantic. This is what I have to deal with from my WYSIWYG. EDIT: I added a potential solution ( that seems to work ) I figure others will run into this problem as well. I'm not sure it's the best... and it's probably not totally robust ( in fact, I know it isn't ), but I'd appreciate any feedback

    Read the article

  • Break NSString using an NSString, get everything after the string that was used to break/separate.

    - by Cole
    I'm trying to get the DOE,JOHN from the below NSString: IDCHK9898960101DL00300171DL1ZADOE,JOHN I was trying to split the string on 1ZA, as that will be constant. Here's what I've tried so far, but it's giving me the opposite of what I'm looking for: NSString *getTheNameOuttaHere = @"IDCHK9898960101DL00300171DL1ZADOE,JOHN"; // scan for "1ZA" NSString *separatorString = @"1ZA"; NSScanner *aScanner = [NSScanner scannerWithString:getTheNameOuttaHere]; NSString *thingsScanned; [aScanner scanUpToString:separatorString intoString:&thingsScanned]; NSLog(@"container: %@", thingsScanned); Output: container: IDCHK9898960101DL00300171DL Any help would be great! Thanks!

    Read the article

  • jsf output text with fn substring

    - by user2361862
    I want to format a date in jsf which is xmlgregoriancalendar type. I've come across post which say I need custom converter. Does anybody found solution which does not require custom date converter. I was trying following but I gives me error saying... Element type "h:outputText" must be followed by either attribute specifications, "" or "/". This is what I tried on jsf <h:outputText value="#{fn:substringBefore(aClip.lastTransmittedDate,"T")}"> <f:convertDateTime pattern="dd.MM.yyyy" /> </h:outputText> Can anybody point out the explain the error I'm getting?

    Read the article

  • Substring and its reverse in a string

    - by christa
    My professor was talking about this in a Dynamic programming class and asked us to think over it. She gave us some examples as well. Given a string, we were to find the longest continuous subsequence whose reverse is also a subsequence present in the given string. Example: INPUT: pqrstuvtsrv OUTPUT: i=3, k=2 rst -> tsr (rst found first at i=3 and for 2 more positions) INPUT: mpqrsrqp OUTPUT: i=2, k=6 pqrsrqp in reverse INPUT: mmpqssss OUTPUT: i=5, k=3 I thought of putting the string and its reverse into 2 different arrays and comparing character by character. But I'm sure this is not the best way to do it. Any suggestions as to what could be the most efficient ?

    Read the article

  • C: evaluate part of the string

    - by Halst
    I cant find an expression to evaluate a part of a string. I want to get something like that: if (string[4:8]=='abc') {...} I started writing like this: if (string[4]=='a' && string[5]=='b' && string[6]=='c') {...} but if i need to evaluate a big part of string like if (string[10:40] == another_string) {...} then it gets to write TOO much expressions. Are there any ready-to-use solutions?

    Read the article

  • iPhone colorize UILabel substrings

    - by Janosch R
    Hey, I’m parsing a twitter rss feed, and I just need to show tweets, so I don't need MGTwitterEngine. I have already set it up so I can see the complete tweet, the only thing I want it to colorize hashtags and urls. So I would need to slice up the string in different substrings, colorize the hashtags and urls and glue it together in various UILabels Is there an easier way to accomplish this? In short I need some parts of a string colored differently than others.

    Read the article

  • Python: How efficient is subtring extraction?

    - by Cameron
    I've got the entire contents of a text file (at least a few KB) in string myStr. Will the following code create a copy of the string (less the first character) in memory? myStr = myStr[1:] I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do this? Thanks!

    Read the article

  • Java strings and substrings

    - by omaxgreen
    hey folks, Can someone help me with this Java problem? I want to write a method that takes two strings as arguments and returns true if each character (including space and punctuation) that appears in one string also appears in the other. Thanks

    Read the article

  • named_scope and substings

    - by Philb28
    I have a named_scope in rails that finds episodes by there directors given name named_scope :director_given, lambda { |dr| {:joins => :director, :conditions => ['given = ?', dr]} } It works great but I would like it to also work on substrings one the name. e.g. instead of having to search for 'Lucy' you could just search 'Lu'. P.S. I also have another named scope which does exactly the same thing but on the directors last name. It there a way to combine the two? Thanks,

    Read the article

  • Perl : get substring which matches refex error

    - by Michael Mao
    Hi all: I am very new to Perl, so please bear with my simple question: Here is the sample output: Most successful agents in the Emarket climate are (in order of success): 1. agent10896761 ($-8008) 2. flightsandroomsonly ($-10102) 3. agent10479475hv ($-10663) Most successful agents in the Emarket climate are (in order of success): 1. agent10896761 ($-7142) 2. agent10479475hv ($-8982) 3. flightsandroomsonly ($-9124) I am interested only in agent names as well as their corresponding balances, so I am hoping to get the following output: agent10896761 -8008 flightsandroomsonly -10102 agent10479475hv -10663 agent10896761 -7142 agent10479475hv -8982 flightsandroomsonly -9124 For later processes. This is the code I've got so far: #!/usr/bin/perl -w open(MYINPUTFILE, $ARGV[0]); while(<MYINPUTFILE>) { my($line) = $_; chomp($line); # regex match test if($line =~ m/agent10479475/) { if($line =~ m/($-[0-9]+)/) { print "$1\n"; } } if($line =~ m/flightsandroomsonly/) { print "$line\n"; } } The second regex match has nothing wrong, 'cause that is printing out the whole line. However, for the first regex match, I've got some other output such like: $ ./compareResults.pl 3.txt 2. flightsandroomsonly ($-10102) 0479475 0479475 3. flightsandroomsonly ($-9124) 1. flightsandroomsonly ($-8053) 0479475 1. flightsandroomsonly ($-6126) 0479475 If I "escape" the braces like this if($line =~ m/\($-[0-9]+\)/) { print "$1\n"; } Then there is never a match for the first regex... So I stuck with a problem of making that particular regex work. Any hints for this? Many thanks in advance.

    Read the article

  • MySQL query String contains

    - by arik-so
    Hello. This may sound easy, but I've been trying - in vain, apparently - to figure out how I can make a query with MySQL that checks if the value (string $haystack ;) ) in a certain column contains certain data ( $needle ;) ), like this: mysql_query(" SELECT * FROM `table` WHERE `column`.contains('{$needle}') "); In PHP, the function is called substr($haystack, $needle), so maybe: WHERE substr(`column`, '{$needle}')=1 Thanks in advance!

    Read the article

  • Finding partial substrings within a string

    - by Peter Chang
    I have two strings which must be compared for similarity. The algorithm must be designed to find the maximal similarity. In this instance, the ordering matters, but intervening (or missing) characters do not. Edit distance cannot be used in this case for various reasons. The situation is basically as follows: string 1: ABCDEFG string 2: AFENBCDGRDLFG the resulting algorithm would find the substrings A, BCD, FG I currently have a recursive solution, but because this must be run on massive amounts of data, any improvements would be greatly appreciated

    Read the article

  • Remove Trailing Slash From Batch File Input

    - by Brook
    I have a batch file that I want to improve. Instead of requiring a user to provide a folder path without a trailing slash, is there an easy way for me to just remove the last character from the path if there is a slash on the end? :START @echo What folder do you want to process? (Provide a path without a closing backslash) set /p datapath= ::Is string empty? IF X%datapath% == X GOTO:START ::Does string have a trailing slash? IF %datapath:~-1%==\ GOTO:START

    Read the article

  • Substring extraction using bash shell scripting and awk

    - by rohanbk
    So, I have a file called 'dummy' which contains the string: "There is 100% packet loss at node 1". I also have a small script that I want to use to grab the percentage from this file. The script is below. result=`grep 'packet loss' dummy` | awk '{ first=match($0,"[0-9]+%") last=match($0," packet loss") s=substr($0,first,last-first) print s}' echo $result I want the value of $result to basically be 100% in this case. But for some reason, it just prints out a blank string. Can anyone help me?

    Read the article

  • How can we extract substring of the string by position and sepretor.

    - by Harikrishna
    How can we divide the substring from the string Like I have string String mainString="///Trade Time///Trade Number///Amount Rs.///"; Now I have other string String subString="Amount" Then I want to extract the substring Amount Rs. with the help of second string named subString not by any other method But it should be extracted through two parameters like first is I have index no of Amount string and second is until the next string ///.

    Read the article

  • Finding ALL positions of a substring in a large string in C#

    - by Tommy
    Alright, so what i have, is a large string i need to parse, and what i need to happen, is find all the instances of extract"(me,i-have lots. of]punctuation, and store them to a list. So say this piece of string was in the beginning and middle of the larger string, both of them would be found, and their index's would be added to the List. and the List would contain 0 and the other index whatever it would be. Ive been playing around, and the string.IndexOf does almost what i'm looking for, and ive written some code. But i cant seem to get it to work: List<int> inst = new List<int>(); int index = 0; while (index < source.LastIndexOf("extract\"(me,i-have lots. of]punctuation", 0) + 39) { int src = source.IndexOf("extract\"(me,i-have lots. of]punctuation", index); inst.Add(src); index = src + 40; } inst = The list source = The large string Any better ideas?

    Read the article

  • Finding all instances of a substring in a string

    - by Mr Aleph
    In my last question I asked about parsing the links out of an HTML page. Since I haven't found a solution yet I thought I tried something else in the meantime: search for every <a href= and copy whatever is there until I hit a </a>. Now, my C is a bit rusty but I do remember i can use strstr() to get the first instance of that string, but how do I get the rest? Any help is appreciated. PS: No. This is not homework on school or something like that. Just so you know.

    Read the article

  • string parsing and substring in c

    - by Josh
    I'm trying to parse the string below in a good way so I can get the sub-string stringI-wantToGet: const char *str = "Hello \"FOO stringI-wantToGet BAR some other extra text"; str will vary in length but always same pattern - FOO and BAR What I had in mind was something like: const char *str = "Hello \"FOO stringI-wantToGet BAR some other extra text"; char *probe, *pointer; probe = str; while(probe != '\n'){ if(probe = strstr("\"FOO")!=NULL) probe++ else probe = ""; // Nulterm part if(pointer = strchr(probe, ' ')!=NULL) pointer = '\0'; // not sure here, I was planning to separate it with \0's } Any help will be appreciate it.

    Read the article

  • Tear subString from within HTML tags with JAVA

    - by asaf
    Hi! let say i have a string like this "neverMindWhat is upneverMind" and I want to take out the What is up using regexp with JAVA. Someone told me that using matcher will be the best. Can anyone show me how to do it using Matcher? Other solutions are welcome too! Thanks!

    Read the article

  • How can we extract substring of the string by position and separator.

    - by Harikrishna
    How can we divide the substring from the string Like I have string String mainString="///Trade Time///Trade Number///Amount Rs.///"; Now I have other string String subString="Amount" Then I want to extract the substring Amount Rs. with the help of second string named subString not by any other method But it should be extracted through two parameters like first is I have index no of Amount string and second is until the next string ///.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >