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 9196033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:45:40+00:00 2026-06-17T21:45:40+00:00

Here is a regex pattern I created in Objective C: ^\n?([#]{1,2}$|[*]{1,2}$|[0-9]{1,3}.$) I want to

  • 0

Here is a regex pattern I created in Objective C:

^\n?([#]{1,2}$|[*]{1,2}$|[0-9]{1,3}.$)

I want to match:

  1. starts with \n or empty
  2. ends with # or * or .
  3. if ends with . there will be 1 or 2 or 3 digits in between
  4. If ends with # or *, there could be 1 more # or * in between

The regex I created matches ‘\n1#’ which is not what I want.
Can anyone help me correct this? Is this fastest one? The regex will be used frequently, so I want it to be as fast as possible.

UPDATE:

Here’s a sample strings for testing:

"\n#", "11*1", "1#", "a1.", "111*", "\n1#", "\n11.", "a11.", "1. ", "*1."

The 1# and 111* were matched. Not sure what went wrong.

  • 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-17T21:45:41+00:00Added an answer on June 17, 2026 at 9:45 pm

    You’re matching #1 and 111# because of [0-9]{1,3}.. You haven’t escaped the . and this group basically matches any sequence of 1 to 3 digits followed by any character.

    What you’re looking for is

    ^\n?(#{1,2}|\*{1,2}|[0-9]{1,3}\.)$
    

    Properly escaped in ObjC, it would be

    @"^\n?(#{1,2}|\\*{1,2}|[0-9]{1,3}\\.)$"
    

    If this regex is used quite a lot, you might want to cache the NSRegularExpression object to avoid compiling it everytime.

    Regexpal is very useful to test regular expressions.

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

Sidebar

Related Questions

Here is my regex pattern: [Ss]ection\s\d+(?![a-zA-z])(?!</ref>) For example, it should match: section 5 or
Here's what I need- RegEx to match a url pattern and rewrite it to
I want to route url through Zend route regex with Swedish character and here
Trying to create a regex pattern for email address check. That will allow a
I'm trying to create a regex pattern to match the lines in the following
my regex match in VBA (WORD) only gives one result. I created this function
Suppose I have a regex pattern and I want to replace the matches of
I have a little problem on RegEx pattern in c#. Here's the rule below:
I created a regex pattern that works in Dreamweaver's regex Find, but when dropped
I am trying to create a regex in Java to match the pattern of

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.