AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Put here requests of problems with regular expressions
Goto page Previous  1, 2, 3 ... , 17, 18, 19  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Visioneer



Joined: 19 Nov 2007
Posts: 42

PostPosted: Sun Jul 20, 2008 3:46 pm    Post subject: Reply with quote

I need a regex for use with SetTitleMatchMode regex that can handle
IE Titles. Think of as TRUE titles. It should ignore the trailing
space-space Microsoft Internet Explorer (or slight deviations that a
user/publisher could have installed). It should also ignore a very possible,
leading URLspace-space that appears on fullscreen/popup IE windows in
XPsp2+ It's supposed to be a security thing, but since you can't see it,
(as it is fullscreen, I don't know why MSDN did it.) But you can see the
trend is to always add leading URLs to browser titles. Of course, since
this won't happen on some windows, it must match the desired Title
without the leading URL. I imagine the trailing part would be constant
though.

It would in effect be a SetTitleMatchMode 3 for IE Titles. Yippee !

I would also appreciate the companion regex example for trimming
WinGetTitle vars in the same fashion..

Also IMHO, I would really like to see a TRUE SetTitleMatchMode, T or
SetTitleMatchMode UNIVERSAL that could be made the default (at top of
scripts), You could put in the regex that you want applied to all your
WinTitle and optionally WinGetTitle stuff. This way you could use for
example: SetTitleMatchMode, 1/3 but also have the UNIVERSAL backing
you up.

This way, when people realize their fullscreen/popup (and god knows what
else in the future) windows access have stopped working, they could
quickly adjust the entire program and avoid countless hours of mindless
code reprogramming.


Last edited by Visioneer on Mon Jul 28, 2008 11:15 pm; edited 1 time in total
Back to top
View user's profile Send private message
joebodo



Joined: 28 Apr 2008
Posts: 45

PostPosted: Sat Jul 26, 2008 6:26 am    Post subject: Reply with quote

I have some data that looks like the following:

Code:
<Redstone/website/:: >
<Redstone/website/type/:: >website</Redstone/website/type/>
<Redstone/website/name/:: >test.com</Redstone/website/name/>
</Redstone/website/>


Running the following:
Code:
entry := RegExReplace(entry, "S)(?<=<)(\/)?(?:(\w+)\/)+(?(1)|:: )", "$1$2")

produces:

Code:
<website>
<type>website</type>
<name>test.com</name>
</website>


I would like to, instead, generate the following from the input data:

Code:
<website/:: >
<website/type/:: >website</website/type/>
<website/name/:: >test.com</website/name/>
</website/>


Any help with the RegExReplace would be appreciated.


Last edited by joebodo on Sun Jul 27, 2008 1:08 am; edited 2 times in total
Back to top
View user's profile Send private message
UIO1
Guest





PostPosted: Sat Jul 26, 2008 11:55 am    Post subject: Reply with quote

Hi, I am navigating through tons of sgml code, and really would like to pare it down this way....

parse rule: any line that contains this, is a line that is entirely removed
bean="150"

so a read in of sgml.txt might be
Code:

<xyz bean="160" data="6722"/>
<xyz bean="150" data="6834"/>
<xyz bean="150" data="4811"/>
<xyz bean="150" data="0833"/>
<xyz bean="150" data="6722"/>
<xyz bean="160" data="6885"/>
<xyz bean="160" data="1131"/>
<xyz bean="150" data="6885"/>
<xyz bean="160" data="3145"/>


would write out to sgml_parsed.txt like,
Code:

<xyz bean="160" data="6722"/>
<xyz bean="160" data="6885"/>
<xyz bean="160" data="1131"/>
<xyz bean="160" data="3145"/>


Smile

can someone please help me with this problem? Very Happy
Back to top
guest_of_the_day
Guest





PostPosted: Sat Jul 26, 2008 12:40 pm    Post subject: Reply with quote

UIO1 wrote:
parse rule: any line that contains this, is a line that is entirely removed
bean="150"
so a read in of sgml.txt might be
Code:
<xyz bean="160" data="6722"/>
<xyz bean="150" data="6834"/>
<xyz bean="150" data="4811"/>
<xyz bean="150" data="0833"/>
<xyz bean="150" data="6722"/>
<xyz bean="160" data="6885"/>
<xyz bean="160" data="1131"/>
<xyz bean="150" data="6885"/>
<xyz bean="160" data="3145"/>

would write out to sgml_parsed.txt like,
Code:

<xyz bean="160" data="6722"/>
<xyz bean="160" data="6885"/>
<xyz bean="160" data="1131"/>
<xyz bean="160" data="3145"/>

can someone please help me with this problem? Very Happy


While not using RegEx, this does the job (and is probably faster??)
Code:
sgml =
(
<xyz bean="160" data="6722"/>
<xyz bean="150" data="6834"/>
<xyz bean="150" data="4811"/>
<xyz bean="150" data="0833"/>
<xyz bean="150" data="6722"/>
<xyz bean="160" data="6885"/>
<xyz bean="160" data="1131"/>
<xyz bean="150" data="6885"/>
<xyz bean="160" data="3145"/>
)

output =
loop, parse, sgml, `n
{
  If A_LoopField not contains bean="150"
    output .= A_LoopField . "`n"
}
MsgBox, %output%
ExitApp
Back to top
guest_of_the_day
Guest





PostPosted: Sat Jul 26, 2008 1:01 pm    Post subject: Reply with quote

guest_of_the_day wrote:
While not using RegEx, this does the job (and is probably faster??)

But if you want to do your own benchmarks, Try this:
Code:
#SingleInstance, force
sgml =
(
<xyz bean="160" data="6722"/>
<xyz bean="150" data="6834"/>
<xyz bean="150" data="4811"/>
<xyz bean="150" data="0833"/>
<xyz bean="150" data="6722"/>
<xyz bean="160" data="6885"/>
<xyz bean="160" data="1131"/>
<xyz bean="150" data="6885"/>
<xyz bean="160" data="3145"/>
)

output =
loop, parse, sgml, `n
{
  If !RegExMatch(A_LoopField, "bean=""150""")
    output .= A_LoopField . "`n"
}
MsgBox, %output%
ExitApp
Back to top
UIO1
Guest





PostPosted: Sat Jul 26, 2008 1:03 pm    Post subject: Reply with quote

YES! Thank you!! Wow that is really great and very fast processing! Very Happy

I did have one more question, but this is the only other one I need I think, ... I have been working this problem the other day, ..but there has been a stumbling block to getting it working perfectly:

parse rule: remove just an explicit inner tag, such as bean8, leaving the rest of the string intact

BEFORE
Code:

<xyz bean1="161" data1="6722"/>
<xyz bean2="153" data2="6834"/>
<xyz bean3="156" data3="4811"/>
<xyz bean4="154" data4="0833"/>
<xyz bean5="157" data5="6722"/>
<xyz bean6="169" data6="6885"/>
<xyz bean7="180" data7="1131"/>
<xyz bean8="195" data8="6885"/>
<xyz bean9="201" data9="3145"/>


AFTER
Code:

<xyz bean1="161" data1="6722"/>
<xyz bean2="153" data2="6834"/>
<xyz bean3="156" data3="4811"/>
<xyz bean4="154" data4="0833"/>
<xyz bean5="157" data5="6722"/>
<xyz bean6="169" data6="6885"/>
<xyz bean7="180" data7="1131"/>
<xyz bean8="195" data8="6885"/>
<xyz bean9="201" data9="3145"/>


this is what I have so far, but it seems to chomp the contents of the entire string, not just removing bean8 only Confused

Code:


FileRead, Data, sgml.txt
Data := RegExReplace(Data,"bean8="".+""")
MsgBox, % Data

Back to top
UIO1
Guest





PostPosted: Sat Jul 26, 2008 1:05 pm    Post subject: Reply with quote

oops! ... that after example, was wrong: I mean it should look like:

Code:

<xyz bean1="161" data1="6722"/>
<xyz bean2="153" data2="6834"/>
<xyz bean3="156" data3="4811"/>
<xyz bean4="154" data4="0833"/>
<xyz bean5="157" data5="6722"/>
<xyz bean6="169" data6="6885"/>
<xyz bean7="180" data7="1131"/>
<xyz data8="6885"/>
<xyz bean9="201" data9="3145"/>


i am sorry!
Back to top
guest_of_the_day
Guest





PostPosted: Sat Jul 26, 2008 4:25 pm    Post subject: Reply with quote

UIO1 wrote:
YES! Thank you!! Wow that is really great and very fast processing! Very Happy

I did have one more question

parse rule: remove just an explicit inner tag, such as bean8, leaving the rest of the string intact

BEFORE
Code:

<xyz bean1="161" data1="6722"/>
<xyz bean2="153" data2="6834"/>
<xyz bean3="156" data3="4811"/>
<xyz bean4="154" data4="0833"/>
<xyz bean5="157" data5="6722"/>
<xyz bean6="169" data6="6885"/>
<xyz bean7="180" data7="1131"/>
<xyz bean8="195" data8="6885"/>
<xyz bean9="201" data9="3145"/>

AFTER
Code:

<xyz bean1="161" data1="6722"/>
<xyz bean2="153" data2="6834"/>
<xyz bean3="156" data3="4811"/>
<xyz bean4="154" data4="0833"/>
<xyz bean5="157" data5="6722"/>
<xyz bean6="169" data6="6885"/>
<xyz bean7="180" data7="1131"/>
<xyz data8="6885"/>
<xyz bean9="201" data9="3145"/

Well I don't know where this is going, but to answer your last post, try this:
Code:
#SingleInstance, force
sgml =
(
<xyz bean2="153" data2="6834"/>
<xyz bean3="156" data3="4811"/>
<xyz bean4="154" data4="0833"/>
<xyz bean5="157" data5="6722"/>
<xyz bean6="169" data6="6885"/>
<xyz bean7="180" data7="1131"/>
<xyz bean8="195" data8="6885"/>
<xyz bean9="201" data9="3145"/>
)
innerTag := "bean8"
output := RegExReplace(sgml, innerTag . "=""\d+""\s")
MsgBox, %output%
ExitApp
Back to top
UIO1
Guest





PostPosted: Sun Jul 27, 2008 2:08 am    Post subject: Reply with quote

Can you plz clarify this line

Code:

output := RegExReplace(sgml, innerTag . "=""d+""<here>")
Back to top
UIO1
Guest





PostPosted: Sun Jul 27, 2008 5:08 am    Post subject: Reply with quote

THANK YOU!

Cool ...but i am still kinda having problems removing tags after the first occurrence with this,

please see what i mean,

Code:

#SingleInstance, force
sgml =
(
<xyz bean2="153" data2="6834"/>
<xyz bean3="156" data3="4811"/>
<xyz bean4="154" data4="0833"/>
<xyz bean5="157" data5="6722"/>
<xyz bean6="169" data6="6885"/>
<xyz bean7="180" data7="1131"/>
<xyz bean8="195" data8="6885"/>
<xyz bean9="201" data9="3145"/>
)
innerTag := "
data8"
output := RegExReplace(sgml, innerTag . "=""\d+""\s")
MsgBox, %output%
ExitApp

Back to top
guest_of_the_day
Guest





PostPosted: Sun Jul 27, 2008 5:23 am    Post subject: Reply with quote

UIO1 wrote:
Can you plz clarify this line

Code:

output := RegExReplace(sgml, innerTag . "=""d+""<here>")


Code:
 =""d+""\s is:
  =        equal sign  followed by a
  ""       double quote followed by
  \d+      one or more digits followed by a
  ""       double quote followed by
  \s       a single white space character
See RegEx documentation for \s and \d
Back to top
UIO1
Guest





PostPosted: Sun Jul 27, 2008 11:52 pm    Post subject: Reply with quote

Oops, I think we crossed tunnels Wink

What I mean is, what do I replace to fix the code so it can remove instances other than the first one? Very Happy

Thank you for fixing your code
Back to top
UIO1
Guest





PostPosted: Mon Jul 28, 2008 12:00 am    Post subject: Reply with quote

Just to clarify, this is a sample of code unadulterated

Code:


<xyz bean2="153" data2="6834 cool2="201""/>
<xyz bean3="156" data3="4811 cool1="201""/>
<xyz bean4="154" data4="0833 cool4="201""/>
<xyz bean5="157" data5="6722 cool4="201""/>
<xyz bean6="169" data6="6885 cool5="201""/>
<xyz bean7="180" data7="1131 cool5="201""/>
<xyz bean8="195" data8="6885 cool6="201""/>
<xyz bean9="201" data9="3145" cool7="201"/>




You see, if I specify data9, or cool4, ... it will not remove those... so the script is useless to me because 90% of the changes I might make will not just be the first instance. I am sorry, I did review your link, but it didn't help me to understand what I needed to do Cool

I do realise this is a hard one, but I feel like my earlier request was being mis-constructed. The Please Clarify question, was already addressed by you? Confused
Back to top
Krogdor



Joined: 18 Apr 2008
Posts: 1090
Location: The Interwebs

PostPosted: Mon Jul 28, 2008 1:36 am    Post subject: Reply with quote

Code:
output := RegExReplace(sgml, innerTag . "=""\d+""\s|(/)","$1")


That should do the trick, I believe. Remove the part in red if you don't want to keep the trailing forward slash.
Back to top
View user's profile Send private message AIM Address
UIO1
Guest





PostPosted: Mon Jul 28, 2008 2:38 am    Post subject: Reply with quote

Very Happy Cool

Check this

Code:

#SingleInstance, force
sgml =
(
<xyz bean2="153" data2="6834"/>
<xyz bean3="156" data3="4811"/>
<xyz bean4="154" data4="0833"/>
<xyz bean5="157" data5="6722"/>
<xyz bean6="169" data6="6885"/>
<xyz bean7="180" data7="1131"/>
<xyz bean8="195" data8="6885"/>
<xyz bean9="201" data9="3145"/>
)
innerTag := "data8"
output := RegExReplace(sgml, innerTag . "=""\d+""\s|(/)","$1")

MsgBox, %output%
ExitApp



but it does work good only on first column with this, ... Confused

Code:

#SingleInstance, force
sgml =
(
<xyz bean2="153" data2="6834"/>
<xyz bean3="156" data3="4811"/>
<xyz bean4="154" data4="0833"/>
<xyz bean5="157" data5="6722"/>
<xyz bean6="169" data6="6885"/>
<xyz bean7="180" data7="1131"/>
<xyz bean8="195" data8="6885"/>
<xyz bean9="201" data9="3145"/>
)
innerTag := "bean8"
output := RegExReplace(sgml, innerTag . "=""\d+""\s|(/)","$1")

MsgBox, %output%
ExitApp

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2, 3 ... , 17, 18, 19  Next
Page 18 of 19

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group