Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. c++ quetion string- int get the last character

c++ quetion string- int get the last character

Scheduled Pinned Locked Moved Solved General and Desktop
c++stringint
2 Posts 2 Posters 638 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RuWex
    wrote on last edited by
    #1

    if I have many string like this:
    "hello250"
    "dog256454"
    "boy14" and etc...
    but the concept is always string->int
    how can I get the last char before the number- integer?

    JonBJ 1 Reply Last reply
    0
    • R RuWex

      if I have many string like this:
      "hello250"
      "dog256454"
      "boy14" and etc...
      but the concept is always string->int
      how can I get the last char before the number- integer?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @RuWex

      • Iterate along the characters in the string till you find a digit; or
      • QString::indexOf(QRegularExpression("m[0-9]")) probably does this.

      The last character before the digit is the index minus 1.

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved