mIRC Homepage

need help defining a string

Posted By: latumus

need help defining a string - 10/10/05 05:19 AM

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?
Posted By: Lpfix5

Re: need help defining a string - 10/10/05 05:56 AM

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..
Posted By: latumus

Re: need help defining a string - 10/10/05 05:59 AM

the .from is the same in every instance
Posted By: Lpfix5

Re: need help defining a string - 10/10/05 06:05 AM

then $remove($3,.from.here) etc.. replace dots with $chr commands if you have too..

i believe its $chr(46)
Posted By: latumus

Re: need help defining a string - 10/10/05 06:07 AM

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
Posted By: RusselB

Re: need help defining a string - 10/10/05 07:20 AM

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.
Posted By: coax

Re: need help defining a string - 10/10/05 08:04 AM

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.
Posted By: Riamus2

Re: need help defining a string - 10/10/05 03:09 PM

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.
Posted By: latumus

Re: need help defining a string - 10/10/05 03:57 PM

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
Posted By: Riamus2

Re: need help defining a string - 10/10/05 05:14 PM

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
Posted By: latumus

Re: need help defining a string - 10/10/05 05:17 PM

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
Posted By: FiberOPtics

Re: need help defining a string - 10/10/05 05:56 PM

; 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
}
Posted By: latumus

Re: need help defining a string - 10/10/05 05:59 PM

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
Posted By: FiberOPtics

Re: need help defining a string - 10/10/05 06:03 PM

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)
Posted By: latumus

Re: need help defining a string - 10/10/05 06:05 PM

thanks alot man
Posted By: latumus

Re: need help defining a string - 10/10/05 10:56 PM

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?
Posted By: hixxy

Re: need help defining a string - 11/10/05 12:00 AM

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
Posted By: Riamus2

Re: need help defining a string - 11/10/05 01:07 PM

Just a note, he wants the output without the episode name... just up until the series/episode number section.
Posted By: latumus

Re: need help defining a string - 11/10/05 10:09 PM

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 =)
Posted By: Riamus2

Re: need help defining a string - 12/10/05 01:05 PM

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
© 2020 mIRC Discussion Forums