Jump to content
  • 0
Alayne

defpattern: regexp, my old ennemy

Question

Hello peoples!

I'd like to create an event based on defpattern, as player may repeat a world generated randomly.

Therefor, according to the level, the event may be partly in capital case.

But I can't find a correct regexp to get the defpattern to match the word (and this only) with the right case.

Knowing that here are some example of words that can be generated:

aerght

arhtGET

aErgEHt

 

Please, help!

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

defpattern is case insentive, but pcre_match (and the regex operator) is not.

This means you could just use "^(.*)$" with defpattern and then filter a second time (the variable is $@p0$) with pcre_match (or ~=) when the event is invoked.

Share this post


Link to post
Share on other sites
  • 0

Ok so basically, this should work, is it?

 

deletepset 1;
	
	defpattern 1, "(.*)", "QuoteALL";
	activatepset 1;
	setnpctimer 0;
	set .Winner,0;	
	waitingroom($seekedWord$, 0);
	
	end;
	
QuoteALL:
	if($seekedWord$ ~= $@p0$)
	{
		//case sensitive check success, do sthg
	}
	end;

 

Share this post


Link to post
Share on other sites
  • 0
OnTalkNearby:
	.@str$ = $@p0$;

	if (.@str$ ~= "your regex here") {
		// do something
	} else if (.@str$ ~= "another regex") {
		// do something else
	}
	// etc
	end;

OnInit:
	.pid = 1; // regex pattern id
	defpattern(.pid, "^(.*)$", "OnTalkNearby");
	activatepset(.pid);

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.