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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:52:57+00:00 2026-05-30T20:52:57+00:00

I’m not sure that regexes are the best solution here, but they seem logical

  • 0

I’m not sure that regexes are the best solution here, but they seem logical enough; I’m just not sure how to actually implement this.

Basically, I want my user to be able to type in a method name and have it parsed for validity after each character input. I have defined a valid function format as a regex, and it is easy enough to test if the two match. The trouble is, I would like to be able to do a partial match, so as to let the user know, “So far, this is valid”.

For example,

+(NSString *)thisIsAValid:(ObjectiveC *)method;

is a valid method. It can be matched by a simple regex string like

[\+-]\(w+\s*\*?\)\w+....etc...

. But I would love to be able to have that same regex string “match”

+(NSStr

(which I realize is sort of a backwards way of using regex). I would still not want the regex to match

Q)(NStr

Is there a way to implement something like this with standard regex functions, or would I have to do something more drastic?

Thanks so much! You guys are invaluable.


After further thinking, I suppose I could make my question a bit more clear (as well as a bit more succinct): Normally, one uses a regex to look for a pattern in text. I.e., how many times does “cat” or “cot” appear in this paragraph. I wish to do the opposite, look for a string “in” a regex. That is, how much of this string, starting from the beginning matches this regex. Ultimately, I would like to return the index at which the string ceases to match the regex in question.

  • 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-05-30T20:52:58+00:00Added an answer on May 30, 2026 at 8:52 pm

    RegexKit seams to use PCRE so you could try to use PCRE directly as it has support for partial matches.

    #include <stdio.h>
    #include <pcre.h>
    
    void test_match(pcre *re, char *subject);
    
    void test_match(pcre *re, char *subject) {
      int rc = pcre_exec(re, NULL, subject, (int)strlen(subject),
                         0, PCRE_PARTIAL, NULL, 0);
      printf("%s: %s\n", subject,
             rc == 0 || rc == PCRE_ERROR_PARTIAL ?
             "match or partial" : "no match");
    }
    
    int main (int argc, const char * argv[]) {
      pcre *re;
      const char *errstr;
      int erroffset;
    
      re = pcre_compile("^ABC$", 0, &errstr, &erroffset, NULL);
      test_match(re, "A");
      test_match(re, "AB");
      test_match(re, "ABC");
      test_match(re, "ABD");
    
      return 0;
    }
    

    Will print:

    A: match or partial
    AB: match or partial
    ABC: match or partial
    ABD: no match
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a

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.