• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Anyone any good at regexp?

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #41
    I'm confused as to why you folks pander to the moronic postings of this Suity post spamming idiot.

    Stop encouraging the twat and maybe he'll grow a brain or with any luck forget to breathe in for a few days which would raise the IQ of CUK a bit.

    Comment


      #42
      ..

      Originally posted by suityou01 View Post
      Ah so you now agree that getting requirements nailed down is important.

      I already told you what I am trying to do, come up with a regexp to parse that string.

      Funnily enough this is to parse emails. The only thing is that the system needs to be configurable. In that I need to be able to define a template that is used to parse the email.

      You now have more requirements than I ever had.
      How is that you could accept such a requirement without qualifying it further?

      Originally posted by suityou01 View Post
      OK. Some bizarre questions (not you Owly that was quite astute).

      I want to listen for an email. Then strip data out of it. I want the system to be configurable so that the pattern matching "stuff" lives in the database.

      So ClientCo then say, right we need a new template I'm not having to roll out a new exe for them.

      So incomes the email. Check the subject line, or address it was sent to or whatever you like, to identify which template to get from the database.

      Then get the template from the database.

      Then use this template to parse the email for data. Then build a comma delimited string of this data. In the order it occurs in the email.

      That's it. No more, no less.

      So if client co then turn up and say, right Suity we want an email that says

      "Apples: 2 Bananas:3 Pears:4" I say sure no problem, just bung a row in that table over there with xyz reg exp I'll just get the solution from my internet friends, shouldn't take more than 15 pages of posts.
      Originally posted by mudskipper View Post
      Now I get it, Suity accepts the first half baked requirement, poses it to the fora as a serious question, we ask him questions then he runs to the LIDL checkout op he works for to get the next piece of the puzzle, this is why he drip feeds

      Comment


        #43
        Or, in other news, no one does regexp and is too stupid not to post and let the thread die a death.

        Lot of hollow vessels on here making far too much noise.

        HTH
        Knock first as I might be balancing my chakras.

        Comment


          #44
          Originally posted by suityou01 View Post
          And then clientco say oh, suity we want to retrieve this piece of data and it looks like :

          *12345*
          That's just (as a preliminary step) a single-field CSV string, with no delimiters.

          Seriously, I would try to get the clients into thinking about and structuring the problem in the way you want them to, or next thing you know they'll be expecting you to parse natural language text.
          Work in the public sector? Read the IR35 FAQ here

          Comment


            #45
            Originally posted by suityou01 View Post
            Or, in other news, no one does regexp and is too stupid not to post and let the thread die a death.
            I'm finding that sentence considerably harder to parse than your example input, despite having known English for longer than I have regular expressions. Are you saying that I shouldn't have posted the regular expression that does what you asked for (insofar as "what you asked for" can be determined)?

            Comment


              #46
              Originally posted by NickFitz View Post
              I'm finding that sentence considerably harder to parse than your example input, despite having known English for longer than I have regular expressions. Are you saying that I shouldn't have posted the regular expression that does what you asked for (insofar as "what you asked for" can be determined)?
              Nick nick nick nick nick. Nicky nick me ole son. Nick dear Nick. Calm yourself.

              You posted some regexp? Let me take a look.

              If it works, the 6 pints are yours.
              Knock first as I might be balancing my chakras.

              Comment


                #47
                Originally posted by NickFitz View Post
                You still haven't said how you want to parse it. Do you want to extract all uppercase letters? All hexadecimal digits that are odd? All non-space characters?

                In default of any clear specification, I shall make the assumption that FolderGUID, Outcome, and DataItem are field labels, the field value follows the label after a colon, and fields are delimited by a single space or the end of the line.

                If that is the case then, in JavaScript (because I can test that in the browser, and I'm not firing up a C# compiler for a no-brainer like this) the following regular expression:

                Code:
                /FolderGUID:([^ ]*) Outcome:([^ ]*) DataItem:(.*$)/
                will give the following array when presented with the input you specified (which is repeated as the complete match at element 0):

                Code:
                [
                    "FolderGUID:67bfabff-ad78-4d30-918e-811dd2636f83 Outcome:Accept DataItem:SomeData",
                    "67bfabff-ad78-4d30-918e-811dd2636f83",
                    "Accept",
                    "SomeData"
                ]
                To generalise it into a function that takes the input as a (single line) string and returns an object with the extracted values as named properties:

                Code:
                function parseLineInWhatOneAssumesToBeTheRequiredWay(line) {
                    var pieces = line.match(/FolderGUID:([^ ]*) Outcome:([^ ]*) DataItem:(.*$)/);
                    if (pieces) {
                        return {
                            folderGUID: pieces[1],
                            outcome: pieces[2],
                            dataItem: pieces[3]
                        };
                    }
                    return null;
                }
                In lieu of a proper specification you managed to piece together this no brainer and come up with the correct answer, so I assume I supplied enough information.

                So ..........

                I owe you 6 pints

                Knock first as I might be balancing my chakras.

                Comment


                  #48
                  ...

                  Originally posted by suityou01 View Post
                  In lieu of a proper specification you managed to piece together this no brainer and come up with the correct answer, so I assume I supplied enough information.

                  So ..........

                  I owe you 6 pints

                  Suity, you could have coded that with Atari Basic in the 80's (not to put Nick's answer down, he could be bothered far more than I could).

                  Do you manage to get through every contract like this?

                  Comment


                    #49
                    Originally posted by tractor View Post
                    Suity, you could have coded that with Atari Basic in the 80's (not to put Nick's answer down, he could be bothered far more than I could).

                    Do you manage to get through every contract like this?
                    Bulltulip deflectors now at max.

                    <whiiiiiiiiiiiiiiiiiiiiir>

                    What's that, can't hear you.
                    Knock first as I might be balancing my chakras.

                    Comment


                      #50
                      Why don't you just teach them how to use Outlook rules...

                      Comment

                      Working...
                      X