Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts

    Regarding Regular Expressions

    I'm having trouble with a regular expression.

    My pattern is:
    Code:
    \[img\][a-z\.0-9]\[/img\]
    And my sample text is just gohasghiohg [ img]enter8.gif[/ img] dsfsf

    (I had to add spaces in to the img tags to prevent the vB code from grabbing them)

    I'm trying to find any occurances of the img tags cuz then it will give me the position and the length. But i'm having trouble with the pattern.

    I don't have much experience with regular expressions so does anyone have any ideas?
    Last edited by oracleguy; 03-16-2003 at 09:16 PM.
    OracleGuy

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Location
    South Africa
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts
    At the moment, your pattern will only look for things like:

    Code:
    [ IMG]p.3[ /IMG]
    I dont think that is what you are looking for...

    You might want to try:
    Code:
    \[IMG\]\w+\.\w+\[/img\]
    This will match anything with the format of:
    Code:
    [ IMG]BLA1_bla2.giF2[ /IMG]
    \w: Matches any alphanumeric character, including the underscore (same as [A-Za-z0-9_]).
    +: Matches 1 or more instances of preceding character.


    If you want more info, go to http://www.4guysfromrolla.com/webtec...ressions.shtml

    Hope I helped

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quite helpful.

    Looks promising, I'll give it a try when I get home.
    OracleGuy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •