Sign in to follow this  
Followers 0
saio

Search for mumbers in txt

8 posts in this topic

I want to find a numbers in a txt file containing: Some Text Number 1 +/-/x/%/ number 2 (eventualy +/-/x/% number 3) and calculate them then whrit them in to Text file2 txt how do i do that???

Share this post


Link to post
Share on other sites



saio,

Can you post an example of the text file from which you need to extract the numbers - it is always easier when we have something to work on. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

that is what it looks like i have input 3 exsamples inside the idea is to get the numbers and than calculate the score and tipe it into text file named Text2.txt

New Text Document (3).txt

Edited by saio

Share this post


Link to post
Share on other sites

saio,

Please help us to help you - are these numbers integers? Decimals? Fractions? ;)

I should not be difficult to write an RegEx to extract them, but we need to see exactly how the line is written to define the pattern. So please post a line so that we can see what we are dealing with. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

saio,

Please help us to help you - are these numbers integers? Decimals? Fractions? ;)

I should not be difficult to write an RegEx to extract them, but we need to see exactly how the line is written to define the pattern. So please post a line so that we can see what we are dealing with. :)

M23

here :

text text text 3+7? (Eventyaly More Text) - example 1

Text Text Text 15-10? (eventualy more text) - exsample 2

Text Text Text 18x3? (eventualy more text) -exsample 3

it's not the same every time and its allays 1 line

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Try this:

#include <array.au3>
$text = _
"text text text 3+7? or 2x3 (Eventyaly More Text) - example 1" & @CRLF & _
"Text Text Text 15-10x3? (eventualy more text) - example 2" & @CRLF & _
"Text Text Text 18x3+1? (eventualy more text) -example 3" & @CRLF & _
"Text Text Text 18%3+1? (eventualy more text) -example 4"

$aResult = StringRegExp($text, "s[d+|+|-|x|%]+d+", 3)
For $i = 0 To UBound($aResult) - 1
    $aResult[$i] = StringReplace($aResult[$i], "x", "*")
    $aResult[$i] = StringReplace($aResult[$i], "%", "/")
    ConsoleWrite($aResult[$i] & "=" & Execute($aResult[$i]) & @CRLF)
Next

I did not implement % and the file write code. What is %? -> implemented

Br,

UEZ

Edited by 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

the numbers and the text is diferent evry thime and the % is /

10/5 =2

&18x3+1? &CRLF &_ unterminated string ....

allso that

$aResult = StringRegExp($text, "s[d+|+|-|x|%]+d+", 3)
For $i = 0 To UBound($aResult) - 1
    $aResult[$i] = StringReplace($aResult[$i], "x", "*")
    $aResult[$i] = StringReplace($aResult[$i], "%", "/")
    ConsoleWrite($aResult[$i] & "=" & Execute($aResult[$i]) & @CRLF)
Next

gives result 1 to 45+8

shud it be something like

For $i = 0 To UBound(99999)......

Allso tryed :

$text4 = ClipGet ()
$aResult = StringRegExp($text4, "s[d+|+|-|x|%]+d+", 3)
      For $i = 0 To UBound($aResult) - 99999
      $aResult[$i] = StringReplace($aResult[$i], "x", "*")
      $aResult[$i] = StringReplace($aResult[$i], "%", "/")
      ConsoleWrite($aResult[$i] & "=" & Execute($aResult[$i]))
   Next

and it still gives 1 .... any help?

I copy to clickboard: 45+8?

is the ? any problem and how to filter it? becose it coud be 45+63? or less simbols 6/8....

Edited by saio

Share this post


Link to post
Share on other sites

Can you provide a real text where we can see what the problem is?

Because 45+8 in a string will be calculated properly!

Otherwise try this here:

$text = ClipGet()
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $text = ' & $text & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

$aResult = StringRegExp($text, "[d+|+|-|x|%]+d+", 3)
For $i = 0 To UBound($aResult) - 1
    $aResult[$i] = StringReplace($aResult[$i], "x", "*")
    $aResult[$i] = StringReplace($aResult[$i], "%", "/")
    ConsoleWrite($aResult[$i] & "=" & Execute($aResult[$i]) & @CRLF)
Next

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
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
Sign in to follow this  
Followers 0