SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Regex and {}

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regex and {}

    Hey everyone, I'm fighting with what I thought would be an easy regex pattern.

    I'm trying to get an array of all strings that are encapsulated within braces.

    ie:
    {this should match}
    this wouldn't
    {but this would}

    I'm using
    Code:
    preg_match_all("{[a-zA-Z]*}", $page->output,$keys);
    print_r($keys);
    And I am actually getting every text match in the file. Including any html tags?

    I thought the braces may have to be escaped, because they are usually considered literal characters unless it is part of a repetition operator? (I could be mistaken). However, escaping them ends up return no matches what-so-ever? I must be missing something quite obvious here....

    Any suggestions?

    Thanks for any input.

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Duh...


    solution for whoever may stumble across this in the future:

    preg_match_all("/{[a-zA-Z]*}/", $page->output,$keys);


Bookmarks

Posting Permissions

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