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. How to write regular expressions

How to write regular expressions

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 232 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.
  • L Offline
    L Offline
    LISP
    wrote on last edited by
    #1

    Hi
    I want to separate only the numbers in brackets [test10] [test25] [test30].
    I tried. I wrote the regular expression below to extract the contents.
    regex("(?<=\[)[^]]*(?=\])")

    result : test10, test25, test30 (remove parentheses)

    But it couldn't separate alphabets and numbers.

    I want to write a regular expression that can extract only the numbers in parentheses.
    And I want to put that number in a list.
    list.append(10)
    list.append(25)
    list.append(30)

    JonBJ 1 Reply Last reply
    0
    • L LISP

      Hi
      I want to separate only the numbers in brackets [test10] [test25] [test30].
      I tried. I wrote the regular expression below to extract the contents.
      regex("(?<=\[)[^]]*(?=\])")

      result : test10, test25, test30 (remove parentheses)

      But it couldn't separate alphabets and numbers.

      I want to write a regular expression that can extract only the numbers in parentheses.
      And I want to put that number in a list.
      list.append(10)
      list.append(25)
      list.append(30)

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

      @LISP
      Assuming your input strings are always <letters><digits> you might replace the [^]]* with something like

      ([A-Za-z]*)\\d*
      

      to capture the letter parts.

      A site like https://regex101.com/ is useful to go play till you get what you want.

      1 Reply Last reply
      1

      • Login

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