Thread Tools Display Modes
02-23-08, 02:13 AM   #1
Tornik
A Defias Bandit
Join Date: Feb 2008
Posts: 3
inputString/string.gsub Help Required

I'm trying to re-work the Pirate Speak mod it to use internally in my guild - we're rolling up a small alt-guild made up of Orcs, and I'm trying to re-write your mod so that we all talk like Orks from Games Workshop's Warhammer 40,000.

Anyhow, most of the code is straight-forward, which is good as my Lua knowledge is hardly in-depth, the only real problem I'm having is when I'm trying to get the mod to change words that share certain sequences of letters. For example, "his" and "this" tend to get mixed up, as do "the" and "their".

I notice in the code use various symbols like ^, [a], $, are used to prevent the same thing, but I can't quite get it to work, and I was hoping there was a way around this. Can anyone help me out, assuming it's straightforward, or maybe point me towards a resource online I could use? I've tried going through the Lua 5.1 manual online, but as I don't quite know how to correctly phrase what I'm looking for, I'm not getting far.
  Reply With Quote
02-23-08, 04:13 AM   #2
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
^ matches the beginning of a string. That is, "^his" will match "his watch" but not "this watch"

$ matches the end of a string. That is, "file$" will match "my file" but not "my files".

Look in PIL for the pattern matching tutorial. PIL can be found at http://www.lua.org/pil and is a bit of an easier read than the manual.
__________________
たしかにひとつのじだいがおわるのお
ぼくはこのめでみたよ
だけどつぎがじぶんおばんだってことわ
しりたくなかったんだ
It's my turn next.

Shakespeare liked regexes too!
/(bb|[^b]{2})/
  Reply With Quote
02-23-08, 06:31 AM   #3
mulesh
A Chromatic Dragonspawn
 
mulesh's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 193
Some links for you:

wowwiki.com's HowTo: Use Pattern Matching
lua-users.org's Patterns Tutorial
__________________
"Don"t tase me bro!" ~ Andrew Meyer
  Reply With Quote
02-23-08, 07:27 AM   #4
Fin
An Aku'mai Servant
 
Fin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 34
Originally Posted by mulesh View Post
Some links for you:

wowwiki.com's HowTo: Use Pattern Matching
lua-users.org's Patterns Tutorial
Also, for reference:

- http://pgl.yoyo.org/luai/i/patterns
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » inputString/string.gsub Help Required

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off