Jump to content

read file and extract a numeric value


Recommended Posts

Hi guys ,

i need your help to finish my tool .

My tool generare a txt file ( eg . pippo.txt )

This is my txt file for example

value 1 : 123aBc123

vaue 2: 345Def345

value 3: 678ghI678

Test Test : 123456

Value 4: abcdefgh

Value 5: ghl12345kkkl

I need to view in a message box the value present in "123456 " position

More info

Test Test : this part is a costant

123456 : is a numeric value only six element

Can you give me advice or suggest a code to view this value ?

Thanks so much for you help

Rgs

AnyB.

Link to comment
Share on other sites

Try this:

$pippo = "value 1 : 123aBc123" & @LF & _
                "vaue 2: 345Def345" & @LF & _
                "value 3: 678ghI678" & @LF & @LF & _
                "Test Test : 123456" & @LF & @LF  & _
                "Value 4: abcdefgh"  & @LF & _
                "Value 5: ghl12345kkkl"
$array = StringRegExp($pippo, "Test.*\s(\d+)", 3)
MsgBox(0, "Test", $array[0])

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Hi to both

@ UEZ

Your code works fine ..but the problem is that my file is very long and not with constant value

This mean that for me this part is hard

$pippo = "value 1 : 123aBc123" & @LF & _                
               "vaue 2: 345Def345" & @LF & _                
            "value 3: 678ghI678" & @LF & @LF & _                
            "Test Test : 123456" & @LF & @LF  & _               
            "Value 4: abcdefgh"  & @LF & _              
            "Value 5: ghl12345kkkl"

Thanks again for your prompt replay

BR

AnyB

Edited by anybastard
Link to comment
Share on other sites

$pippo = FileRead("Pippo.txt")
$array = StringRegExp($pippo, "Test.*\s(\d+)", 3)
MsgBox(0, "Test", $array[0])

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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...