Jump to content

Extract Grouped Digits from String *Urgent*


Gauss
 Share

Recommended Posts

?

$str = 'MATHS: 95 04 PHYSICS:78 6o ENGLISH: 82'


$aScores = StringRegExp($str, "(MATHS|PHYSICS):\h*(\d+)", 3)
For $i = 0 To UBound($aScores) - 1 Step 2
    ConsoleWrite($aScores[$i] & " = " & $aScores[$i + 1] & @CRLF)
Next

Edit : *Urgent* is not necessary

Edited by jguinch
Link to comment
Share on other sites

another way...

#include <array.au3>

$str = 'MATHS: 95 04 PHYSICS:78 6o ENGLISH: 82'
;$aScores = StringRegExp($str, "\w+:\h*\d+", 3)                 ;   get all courses
$aScores = StringRegExp($str, "(?:MATHS|ENGLISH):\h*\d+", 3)    ;   get just MATHS and ENGLISH

_arraydisplay($aScores)

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...