Activity Stream
48,167 MEMBERS
6781 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 39
  1.     
    #21
    Respected Developer
    No, using regex is overkill. I suggest you do some research in to how regular expression engines work internally. As I said before, you can use regex only in very (very very) simple situations. As soon as you try to use it for extracting dynamic data from multiple locations in a document you're screwed with regex. It ain't rocket science.

  2.     
    #22
    Respected Developer
    Website's:
    PlatinumW.org NexusDDL.com HD-United.org CheckLinks.org FLVD.org
    I know how regex works. The way DOM parser works is simple but uses lot of memory and is slower. I find it trivial to waste resources for a simple task such as his. He does not need to extract dynamic data. Using a DOM parser is overkill and waste of resources in this case. It ain't rocket science either.

  3.   Sponsored Links

  4.     
    #23
    Respected Developer
    Quote Originally Posted by Dman View Post
    I know how regex works.
    I don't think you do. If you did you'd agree with me and everyone esle who calls himself a coder.

    Have fun: http://swtch.com/~rsc/regexp/regexp2.html

    Quote Originally Posted by Dman View Post
    The way DOM parser works is simple but uses lot of memory and is slower.
    Sigh. To parse XML/HTML one only needs a simple state machine. Because of that it can be parsed with relatively little code and is much more efficient when compared to the complex finite state machines that make up modern regular expression engines. It requires less CPU cycles than running it trough one or more regular expressions and because of the simplicity of the state machine it uses less memory. Once a DOM is parsed it'll use roughly the same amount of memory as the original string that holds the markup (+ a few KB here and there for the objects).

    Every developer that needs to work with HTML or XML will parse it with state machine and not with regular expressions for said reasons.

    I'll give you another article: http://www.codinghorror.com/blog/200...hulhu-way.html

    Quote Originally Posted by Dman View Post
    I find it trivial to waste resources for a simple task such as his. He does not need to extract dynamic data.
    Erm, you save resources if you simply parse the HTML the way it should be parsed. You might want to re-read the first post. It's clear that he needs dynamic data.

    Quote Originally Posted by Dman View Post
    It ain't rocket science either.
    Apparently for some it is. You know you're wrong here, why not just say I'm right? It's not gonna make you look stupid or anything. We all learn, including me .

    PS: do read those articles.

  5.     
    #24
    Respected Developer
    Website's:
    PlatinumW.org NexusDDL.com HD-United.org CheckLinks.org FLVD.org
    Well from the looks of it, it doesn't look like he wants to parse data but extract it.
    The regular expression reading was very interesting - thanks for the link I am also not clear as to what do you mean by dynamic data?

  6.     
    #25
    Member
    Website's:
    InstantRDP.com
    I am not doing by Hyper'z method or Regex method. Both are new to me, what I require is very simple work, just extracting all links with a given start string and end string from a page which I have already stored as string.

    I am using loop and IndexOf of do it.




  7.     
    #26
    Respected Developer
    ^That too is how it should not be done. It's virtually the same as regular expressions but even less solid. What is so hard about just parsing the HTML file? Why use some confusing dirty method? Anyway, it's your problem. Just know that your code is flawed.

    Quote Originally Posted by Dman View Post
    Well from the looks of it, it doesn't look like he wants to parse data but extract it.
    The regular expression reading was very interesting - thanks for the link I am also not clear as to what do you mean by dynamic data?
    Lol you just don't give up do you ^^. You need to parse data to extract it correctly. By dynamic data I mean data that changes (coming from a PHP file for example). If you look at the 1st post you see he extracts data from a forum which is about as dynamic as it gets.

  8.     
    #27
    Member
    Website's:
    InstantRDP.com
    I already completed coding the part for extracting the string. It was not simple <div> and </div> tag. I had to extract data between two definite pattern of strings.

    So, I didn't want to waste another week learning your method.
    I'll give it time after I complete my project and learn that too though.

    PHP Code: 
     for(int i=0;i<5;i++)
                {                                        
                       
    string result "";
                
    int iIndexOfBegin strSource.IndexOf(strBegin);
                if (
    iIndexOfBegin != -1)
                                {
                    
    String tempstring strSource.Substring(iIndexOfBegin strBegin.Length);
                    
    int iEnd tempstring.IndexOf(strEnd);
                    if (
    iEnd != -1)
                    {
                        
    result tempstring.Substring(0iEnd);
                    
                        
    string next result




  9.     
    #28
    Respected Developer
    What is there to learn about:
    Code: 
    var html = new HtmlDocument();
    
    // load the html
    html.LoadHtml(yourHtmlHere);
    
    // use XPath to select all "A" elements from the html
    var anchors = html.DocumentNode.SelectNodes("//a");
    
    // filter out those that start with http
    var filter = from a in anchors
                 where a.GetAttributeValue("href", "").StartsWith("http")
                 select a;
    ??

    It's just loading a dll and calling a few methods. I don't see what needs to be learned here. What you're doing right there is the wrong way to do it and I wouldn't be surprised if I see you making another topic because suddenly something stopped working or your program crashes.

  10.     
    #29
    ლ(ಠ益ಠლ)
    Website's:
    extremecoderz.com
    Doing what pankaj wants is quickest when using IndexOf - iv been through them all, and thats what conclusion i came to, which is why i created my little "getstringInbetween" class.

  11.     
    #30
    Respected Developer
    But it is not reliable with dynamic data. You need access to the DOM. This is not a situation where execution time is important but rather one where the validity of the data is.

Page 3 of 4 FirstFirst 1234 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. extracting data from diffrent site
    By zebono2 in forum Web Development Area
    Replies: 1
    Last Post: 28th Jul 2012, 06:22 AM
  2. C++ string search help needed
    By googleplus in forum Web Development Area
    Replies: 0
    Last Post: 12th May 2012, 04:42 PM
  3. Replies: 0
    Last Post: 20th Dec 2011, 03:37 AM
  4. php string - heredoc syntax
    By desiboy in forum Web Development Area
    Replies: 3
    Last Post: 16th Nov 2010, 05:15 PM
  5. [c#] Get String In between strings
    By jayfella in forum Web Development Area
    Replies: 3
    Last Post: 16th Jun 2010, 11:23 PM

Tags for this Thread

BE SOCIAL