Jump to content

Recommended Posts

Posted

Hi

I'm trying to obtain a distinct list of special characters a particular field in my database.

In SQL I am using the WHERE clause:

LIKE '%[^0-9a-zA-Z ]%'

What I need to do is loop through the results and grab only the special characters contained within so I can have a full list of the characters and send them to a supplier.

Can anyone recommend a quick way to do this? I can export my SQL results to a text file so no requirement for database connectivity.

An example could be

\xxxxxx

\xxx?xxx

^xxx^xxx

Thanks

Posted

Looks like a job for regular expressions: Function StringRegExp

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

My first try on regular expressions:

#include <Array.au3>
$aMatches = StringRegExp("/xxx'xÄxx", "[^0-9a-zA-Z]", 3)
_ArrayDisplay($aMatches)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 1/17/2013 at 3:53 PM, 'water said:

My first try on regular exp<b></b>ressi&#111;ns:

#include <Array.au3>
$aMatches = StringRegExp("/xxx'xÄxx", "[^0-9a-zA-Z]", 3)
_ArrayDisplay($aMatches)

Looks fine to me or you could use w, but this includes "_" (underscore) so best to stick with that class.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

#include <Array.au3>

$sText = "¤ Hello THere " & @CR
Local $aRet = StringRegExp( $sText, "([^\w\h\v]+)", 3 ) ;Matches any thing other than a word, horizontal/vertical space.
_ArrayDisplay( $aRet )

Edited by PhoenixXL

My code:

  Reveal hidden contents
PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Posted

Thanks for the quick response guys.

Since I am getting a blank file I am clearly doing something wrong........

#include <Array.au3>
#include <file.au3>

$file = @SCRIPTDIR & "\textin.txt"
$out = @SCRIPTDIR & "\out.txt"
FileDelete($out)

Dim $aRecords
If Not _FileReadToArray($file, $aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $aRecords[0]
    $char = StringRegExp($aRecords[$x], "([^\w\h\v]+)", 3)
    FileWriteLine($out, $char)
Next
Posted (edited)

Yes. StringRegExp returns an array.

FileWriteLine($out, _ArrayToString($char, ""))
should help

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
:D

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

kiffab,

Avoid using Dim if you can. Actually, there is no reason why Dim should be used.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
  • Recently Browsing   0 members

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