Regular Expression (newbie)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cristisor

    Regular Expression (newbie)

    Hi. I'm not good at all with regular expressions, so maybe someone can
    help me with this: I need to create a regular expression that accepts
    everything except the word upload. The regular expression for
    everything is this: [a-zA-Z_0-9]+, but how can I solve the second part
    of my problem? Thank you!
  • Michael Fesser

    #2
    Re: Regular Expression (newbie)

    ..oO(Cristisor)
    >Hi. I'm not good at all with regular expressions, so maybe someone can
    >help me with this: I need to create a regular expression that accepts
    >everything except the word upload. The regular expression for
    >everything is this: [a-zA-Z_0-9]+, but how can I solve the second part
    >of my problem? Thank you!
    You don't need a regex here. Simply use strpos() to check for the word
    "upload".

    Micha

    Comment

    • Cristisor

      #3
      Re: Regular Expression (newbie)

      On Oct 5, 7:59 pm, Michael Fesser <neti...@gmx.de wrote:
      .oO(Cristisor)
      >
      Hi. I'm not good at all with regular expressions, so maybe someone can
      help me with this: I need to create a regular expression that accepts
      everything except the word upload. The regular expression for
      everything is this: [a-zA-Z_0-9]+, but how can I solve the second part
      of my problem? Thank you!
      >
      You don't need a regex here. Simply use strpos() to check for the word
      "upload".
      >
      Micha
      my problem is that I have e regular expression in a .yml file and I'm
      using it for some kind of validation, to know when to include or not
      something. so I don't think I can use strpos() in this file, right?
      thanks for the help Micha

      Comment

      • Curtis

        #4
        Re: Regular Expression (newbie)

        Cristisor wrote:
        On Oct 5, 7:59 pm, Michael Fesser <neti...@gmx.de wrote:
        >.oO(Cristiso r)
        >>
        >>Hi. I'm not good at all with regular expressions, so maybe someone can
        >>help me with this: I need to create a regular expression that accepts
        >>everything except the word upload. The regular expression for
        >>everything is this: [a-zA-Z_0-9]+, but how can I solve the second part
        >>of my problem? Thank you!
        >You don't need a regex here. Simply use strpos() to check for the word
        >"upload".
        >>
        >Micha
        >
        my problem is that I have e regular expression in a .yml file and I'm
        using it for some kind of validation, to know when to include or not
        something. so I don't think I can use strpos() in this file, right?
        thanks for the help Micha
        Can you be more specific about what your overall goal is? Maybe
        posting a sample of the yml file, and clearly showing what you're
        trying to look at in the file would be more helpful.

        You can read the yml file into a PHP string with file_get_conten ts,
        and check for "upload" before including the file. strpos() would work
        in the PHP file that does the including.

        --
        Curtis

        Comment

        • Cristisor

          #5
          Re: Regular Expression (newbie)

          This is how the .yml file look like:
          dizy_WebApp[A-Za-z_]*:
          [a-zA-Z_0-9]+:
          - /overlib/overlib_mini.js
          - /prototype/prototype.js
          .........
          browseCommunity |overview:
          - /gadget.js

          So for everything I include prototype.js and the other file for
          overview I include also gadget.js, but there is one situation where I
          don't want to include prototype.js because I'm including another
          framework and this makes the application crash because they can't work
          together. So either I give up including prototype.js everywhere and I
          include manually in every file, or I find a regular expression that
          doesn't allow me to include prototype when I'm in this module called
          uploadImage. Thank you

          Comment

          Working...