Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 8:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How do I create a 'mask' for String Search?
PostPosted: March 11th, 2009, 1:47 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
How would I implement a search of a Text Object using a 'mask'?

I want to embed the following markers in the text, and then find them at runtime. Assume that I will have many of these throughout the Pub.

*SB81032*
*SBK2003*
*SBT4550*

Run through a Loop.
var myArray[i] = Textobj23.FindText( "*SB?????*", nextIdx )

*SB and the ending * are the consistent characters. While the ?'s represent wildcards. (I don't need those to be ?-marks). How to do this efficiently?

TIA.
Larry

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: March 11th, 2009, 9:48 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Morning Lar,

Ideally, this would be a case for regexp() but OpusScript doesn't yet support that function so unless you're pulling the text from a database, you'll need to write a custom function.

Because your matching is simple, try using an incrementing check with charAt()

if (o.charAt(i) == '*' && o.charAt(i+1) == 'S' && o.charAt(i+2) == 'B' & charAt(i+8) == '*)
{
fnc_extract_match(i)
} else
{
i++
}

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 11th, 2009, 11:44 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Thanks Mack. That gets me going in a plausible direction. However I wanted to be more lazy than that this week. And maybe a trip back to the drawing board to find some ways I can simplify before I start.

I am pulling sections of text from a DB, but text will be read-in and then decrypted when in Opus.

Thx.
Larry

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group