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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:24:36+00:00 2026-06-18T11:24:36+00:00

I am trimming an NSString in the following way: NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@X

  • 0

I am trimming an NSString in the following way:

NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"X = (\\d+.\\d+), Y = (\\d+.\\d+), (%@)" options:0 error:NULL];
NSTextCheckingResult *match = [regex firstMatchInString:txt.text options:0 range:NSMakeRange(0, [txt.text length])];
if (match) {
    NSRange firstHalfRange = [match rangeAtIndex:1];
    NSString *xString = [txt.text substringWithRange:firstHalfRange];
    NSRange secondHalfRange = [match rangeAtIndex:2];
    NSString *yString = [txt.text substringWithRange:secondHalfRange];
    NSRange thirdHalfRange = [match rangeAtIndex:3];
    NSString *colorString = [txt.text substringWithRange:thirdHalfRange];

    NSLog(@"X = %@, Y = %@, Color: %@", yString, xString, colorString);
}

The NSString looks like this:

@"this is the content. The content of this string may vary, as well as the length, and my include any characters, with numbers X = 295.000000, Y = 207.500000, TheWhite"

The part Y = 295.000000 X = 207.500000 remains always the same, apart from the X and Y numbers which may change, as well as the: TheWhite, which may become for e.g. TheBlack

Using this method I successfully extract the X and Y values, but not the final string. What am I doing 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-18T11:24:37+00:00Added an answer on June 18, 2026 at 11:24 am

    Your pattern ends with (%@). I should end with (.+) instead.

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

Sidebar

Related Questions

Is there a way to specify text trimming on a TextBlock to be from
text block how to do: text trimming for a given height vertical alignment Can
I'm having a hard time with trimming some characters from a NSString. Given an
Is there an easy way of trimming whitespace off of char-type columns when using
What a best way for trimming all strings in string list? I try to
Could you please help with preg_replace regex for trimming letter/words if appears after 2
So I am trimming a path that looks like this: E:\folder\00000000\file.txt I want to
I'm looking for a solution for trimming an unknown text to certain length. Keeping
I'm looking for examples for building a text-trimming cell for GWT DataGrid. I want
I have a weird trimming problem here. I have a txt file of about

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.