Jump to content

Recommended Posts

Posted (edited)

Hihi,

I will be honest and direct. I suck in regular expressions. In autoit, in c#, in c++ everywhere i go.
So an old friend had made these patters for me in autoit and i need them now in c#. Unfortunatly i have no more contacts with him so he can't help me.
So the patterns he made for me are these:

Local rules_1 = "(?i)\[ilvl:([0-9]{1,2})\]"
Local rules_2 = "(?i)\[q:([0-9]{1,2})\]"
Local rules_3 = "(?i)\(([[:ascii:]+]+)\)"

Can anyone help me here please?

Cheers

Edit: The code for the patterns looks like this:

If StringRegExp($tab, $rules_1) = 1 Then  
 $tab_RegExp = StringRegExp($tab, $rules_1, 2)
  
 $tab = StringReplace($tab, $tab_RegExp[0], "", 0, 2)
  
 $curr_ilvl = $tab_RegExp[1]
 
Else
  
 $curr_ilvl = 0
  
EndIf
Edited by AutID
Posted

DotNetPerls would be a good place to look on using the Regex object. Then you have the quick reference here to see the difference between that and PCRE

As for those patterns they work in AutoIt? When using strings that contain regular expression patterns, use a verbatim literal.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

  On 6/24/2014 at 8:43 AM, guinness said:

DotNetPerls would be a good place to look on using the Regex object. Then you have the quick reference here to see the difference between that and PCRE

As for those patterns they work in AutoIt? When using strings that contain regular expression patterns, use a verbatim literal.

That made my day. Thanks.

Cheers

 

P.S it was a nightmare. To return an array you have to turn the string into maches but then to use other string functions you have to turn the elements of the array back to strings which killed me. After some hours i managed turning the 2 functions i needed into C#. On the other hand i am glad beause i learnt somethings ;)

And thank you for moving the thread, whoever did it ;)

 

Edited by AutID
Posted
  Quote

 

to use other string functions you have to turn the elements of the array back to strings which killed me

Gneh?

Result matches array elements are strings (what else?) which allows you to revive.

  Reveal hidden contents

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

  On 6/25/2014 at 7:58 AM, jchd said:

Gneh?

Result matches array elements are strings (what else?) which allows you to revive.

Yes but if you call a string of an array you can not call all the string function that you can with a simple string.

string[0] which is basically a string

string simple string

I mean if you call string[0] which is a string, not all string functions can be excecuted with this. A lot of them yes but not all without throwing an exception.

You have to convert your string[0] which is a string to string.(Convert.ToString(), string[].ToString() etc...)

C# doesn't support redim so i am working with generics. Even if a Match is equal to a string, you can not use it as a string before converting it to string.

Posted

Now I am lost.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

  On 6/25/2014 at 12:55 PM, guinness said:

Now I am lost.

Well don't be. What jchd is saying is correct.

An array element is a string if you use it like this in c#

Regex rules_1 = new Regex(@"(?i)\[ilvl:([0-9]{1,2})\]");
var match1 = rules_1.Match(String1);
var value1 = match1.Groups[1].Value;   //this is a string
but this is not the way i am doing it.
Posted

I understood jchd.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

You're welcome regardless of whether you undestand yourself or not :)

  Reveal hidden contents

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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