Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8459953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:28:19+00:00 2026-06-10T13:28:19+00:00

namez <- c(foo2003, bar2340, naught45) patternz <- 03 grepl([patternz]$,namez) It does not work. What

  • 0
namez <- c("foo2003", "bar2340", "naught45")
patternz <- "03"
grepl("[patternz]$",namez)

It does not work. What should I substitute [patternz] with, so the regular expression will match the contents of the patternz variable?

[edit] Notice that I want to match the string “03”, not the digits “0” and “3” separately.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:28:20+00:00Added an answer on June 10, 2026 at 1:28 pm

    Must admit to struggling to see what the problem is here. For the example stated nothing more than

    R> namez <- c("foo2003", "bar2340", "naught45")
    R> patternz <- "03"
    R> grepl(patternz, namez)
    [1]  TRUE FALSE FALSE
    

    is required as patternz is a character vector and the aim is not to match 0 & 3 but to match the literal "03"

    If you need this to match only at the end of the strings, then we do need to add "$" either by hand:

    R> patternz2 <- "03$"
    R> grepl(patternz2, namez)
    [1]  TRUE FALSE FALSE
    

    or via a paste0() operation

    R> grepl(paste0(patternz, "$"), namez)
    [1]  TRUE FALSE FALSE
    

    The issue is to use patternz as the actual regexp and base R functions handle this perfectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The name 'Global' does not exist in the current context I'm getting the above
The name 'HttpUtility' does not exist in the current context. I'm a bit stuck
Name is not compliant? Layout? What? Do you have ideas what exactly could generate
named_scope :correct, :include => :correction, :conditions => checked_at IS NOT NULL AND corrections.id IS
select NAME from Temp_EMP where name not in select NAME from EMPLOYEE and deptid
Named local classes are very rarely used, usually local classes are anonymous. Does anybody
Named Pipes ? XML-RPC ? Standard Input-Output ? Web Services ? I would not
I am not sure this is possible with SQL (say we are executing on
Name,Age,Seq G,30,1 G,31,1 K,28,3 K,29,3 k,28,3 V,,4 V,28,4 make sure the records should be
name 'entry_resource' is not defined This is my models.py from tastypie.utils.timezone import now from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.