# Can I get the result of a match?

**URL:** <https://racket.discourse.group/t/can-i-get-the-result-of-a-match/943>\
**Category:** Questions & Answers\
**Tags:** question\
**Created:** [April 30, 2022, 2:49am UTC](https://racket.discourse.group/t/can-i-get-the-result-of-a-match/943 "2022-04-30T02:49:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertpostill](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robertpostill/32/53_2.png) [@robertpostill](https://racket.discourse.group/u/robertpostill)\
**Post date:** [April 30, 2022, 2:49am UTC](https://racket.discourse.group/t/can-i-get-the-result-of-a-match/943/1 "2022-04-30T02:49:14Z")

</div>

I've been on a bit of a tear with match lately but I find myself re-running the match operation to take advantage of the match. For instance:

```scheme
define (find-email candidate)
  (define rule-name "Email Address")
  (define simple-email-regex (pregexp "\\S+@\\S+\\.\\S+"))
  (match candidate
    [(pregexp simple-email-regex)
     (list (regexp-match simple-email-regex candidate)) #t)]
    [_ (list null #f)]))

```

I've simplified the code a little bit but I want to pass back what matched and some metadata (in this case simply a boolean).

I'm looking to tidy up my code and so I wonder if a fellow match user could tell me where match stores the result of the match. So I don't rerun the rexexp match?

---

<div class="post-metadata">

**Author:** ![sorawee](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sorawee](https://racket.discourse.group/u/sorawee)\
**Post date:** [April 30, 2022, 3:17am UTC](https://racket.discourse.group/t/can-i-get-the-result-of-a-match/943/2 "2022-04-30T03:17:51Z")

</div>

The documentation of `pregexp` in `match` indicates that you can put a match pattern after the regexp pattern. In your case, you probably want:

```scheme
(define (find-email candidate)
  (match candidate
    [(pregexp #px"\\S+@\\S+\\.\\S+" match-result)
     (list match-result #t)]
    [_ (list null #f)]))

```

---

<div class="post-metadata">

**Author:** ![robertpostill](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robertpostill/32/53_2.png) [@robertpostill](https://racket.discourse.group/u/robertpostill)\
**Post date:** [May 2, 2022, 10:25am UTC](https://racket.discourse.group/t/can-i-get-the-result-of-a-match/943/3 "2022-05-02T10:25:13Z")

</div>

Thanks, I missed that.
