mIRC Home    About    Download    Register    News    Help

Print Thread
#132368 10/10/05 05:19 AM
Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
i am trying to cut of part of a string,
lets say this string is $3
and it says this.is.a.string.from.here.i.want.to.cut
i want it to to define $3 but without from.here.i.want.to.cut
here comes the tricky part though
this.is.a.string is variable and it has different lengths at all times, also here.i.want.to.cut is also variable and has an undefined lenght. so all i know is i want to keep the beginning up untill .from and i want it to cut untill the end

any suggestions?

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
There has to be something in it the same always else... you cannot do that because if everything is different all the time (variable) then the script varies..


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
the .from is the same in every instance

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
then $remove($3,.from.here) etc.. replace dots with $chr commands if you have too..

i believe its $chr(46)


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
i just know the .from the here etc is variable so i cant use the way you just described seeing i only know the from is there not a way to start it at .from and cut till the end of the $3
everything that comes after.from without defining it seeing i dont know what comes after it

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I don't know if this is what you're looking for, I'm having a bit of a hard time understanding your query (might be due to the fact that it's 3:15 am), but you might try this
Code:
set %variable $findtok(%variable,from,1,46)
tokenize 46 %variable
echo -a $3
  

Ensure that the original string goes into %variable before using that, and it should return to your screen what you're looking for. Amend for the specifics to your code as necessary.

Joined: Oct 2005
Posts: 11
C
Pikka bird
Offline
Pikka bird
C
Joined: Oct 2005
Posts: 11
Yeah me and the thread starter talked about this on irc, and I think I may be able to explain the problem better.

Let's say he wants to make a database of something, and he wants every entry to be unique. He get his data from an announcment in a channel.
The problem is that there can be several duplicates being announced in the same channel of the same entry, only, each entry may be different.

Let's say one format is This.part.is.variable.This.Is.Static.This.Is.Variable

So what happens is that the variables can be duplicates of eachother, but the static page is what he wants to filter out with.
There can be several types of static data, bu he only wants one type, and within that 1 type of static data, there can be several duplicates defined in the variable data.

He wants his database to only log the specific 1 type of static data, and somehow check the variable data for duplicates, then add the entry to the database.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Heh... that was even more confusing to me. laugh

It would help to see a real example of how it looks rather than the fake examples you two have used. Those just cause problems when trying to help.

If you have 2 variables, why not just not use the second variable?

If your "static" data part is a unique word, the code below may be helpful. If it isn't unique and it could be in your variables, then you'll have problems. Also, this assumes you want to remove everything from the word "from" to the end, in your example. Again, if you give a REAL example, it will help greatly.
Code:
//echo -a $gettok(this.is.a.test.from.a.fake.user,1- $+ $calc($findtok(this.is.a.test.from.a.fake.user,from,46) - 1),46)

As you can see, that will display everything up until "from". You could set that as a /var or do whatever else with it you wanted. Including real examples and a better description of what you really want to happen will help.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
All.of.Us.S03E03.Part1.kiss.kiss
Desperate.Housewives.S02E02.Secrets.well.kept

etc
im making a database of tv series
but i dont want dupes the S02E02 is always the same length
and has a .S to start with followed by 2 numbers then a E and another 2numbers ending with a .

that is the only static part
i want to cut EVERYTHING that comes after the last number
as you can see the part in front of that part is variable as well seeing some series have 1 word lenghts and others longer
i hope to have advised you enough to understand the problem

/latumus

Last edited by latumus; 10/10/05 05:03 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
That is definitely easier to understand now. smile

I'll leave this to someone who knows regex as that will be the easiest way to handle this. I've not learned it enough yet to really do this without trying to figure it out and I don't want to try figuring it out right now after just writing a huge script for someone else. laugh


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
so i guess its a matter of the right place at the wrong time
i appreciate you pointing others that might be able to help me into the right direction though.

/latumus

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
; Usage: $cutoff(string) or /cutoff string

Code:
alias cutoff {
  var %a, %b = $regsub($1-,/(?<=S\d\dE\d\d).+/,,%a)
  $iif($isid,return,echo -a) %a
}


Gone.
Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
can you put this in an example using Desperate.Housewives.S02E02.Secrets.well.kept as $3 please
making me only keep Desperate.Housewives.S02E02

/latumus

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Eh?

/cutoff Desperate.Housewives.S02E02.Secrets.well.kept

or

//echo -a $cutoff(Desperate.Housewives.S02E02.Secrets.well.kept)

If $3 contains Desperate.Housewives.S02E02.Secrets.well.kept, then it would be;

//cutoff $3

or

//echo -a $cutoff($3)


Gone.
Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
thanks alot man

Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
ok 1 more (a bit more tricky)
The_West_Wing.7x03.Message_Of_The_Week

i need to strip that as well
so given is that 7x03 will be teh static part in this

digitxdigitdigit

also i'd like to change the _'s to . and change 7x03 to S07E03
in my dupelog

any sugestions?

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:

Code:
alias fixstr { $iif(!$isid,echo -a,return) $or(,$regex(fixstr,$1,/(.+?)(\d+?)x(\d\d.+)/)) $& 
  $replace($+($regml(fixstr,1),S,$base($regml(fixstr,2),10,10,2),E,$regml(fixstr,3)),_,.) }


Input: /fixstr The_West_Wing.7x03.Message_Of_The_Week
Output: The.West.Wing.S07E03.Message.Of.The.Week

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just a note, he wants the output without the episode name... just up until the series/episode number section.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
he gave me exactly what i needed i could use his script
and the other one in one

ie $cutoff($fixstr(episode.blah)

works like a charm =)

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, I know they'd work together... but it's much easier to have one do it all (which it could if written that way). laugh


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard