NetAdminTools.com
 
SignalQ Sites:
NetAdminTools - Coprolite - NoNIC - SpotBridge - NAW
RoboCoop - AreWeDown - SolarPower - SysAdminTools
Xfig - Gold Loaf - GeekPapa - FixGMC - MCJ - FixRambler
Categories:
GNU/Linux | Homebrew designs | Perl | Administration | Backup/Recovery | Bugs/Fixes | Certification | Database | Email | File/Print | Hardware | Information Grab Bag | Interoperability | GNU/Linux ABCs | Monitoring | Name Resolution | Network Services | Networking | Remote Control | Security | Desktop | Web | BSD | Solaris | GIAGD | REALbasic

Last 30 Days | Last 60 Days | Last 90 Days | All Articles | RSS | Hail Support


Categories:
·GNU/Linux
·Homebrew designs
·Perl
·Administration
·Backup/Recovery
·Bugs/Fixes
·Certification
·Database
·Email
·File/Print
·Hardware
·Information Grab Bag
·Interoperability
·GNU/Linux ABCs
·Monitoring
·Name Resolution
·Network Services
·Networking
·Remote Control
·Security
·Desktop
·Web
·BSD
·Solaris
·GIAGD
·REALbasic
·All Categories


Using Regular Expressions With REALbasic
Topic: REALbasic   Posted:2006-05-21
Printer Friendly: Print

spacer
Here is a bit of code from Mountain Climbing Journal that combines an if statement and regular expressions to match an image and display it:

if left(me.SelText,9)="<img src=" AND Keyboard.AsyncControlKey=TRUE then
dim rg as new RegEx
dim match as RegExMatch
dim f as folderItem
dim imgsrc as string
if instr(me.SelText,"/") <> 0 then
rg.SearchPattern="<img src="+chr(34)+"\S*/(\w+\.\w+)"+chr(34)+">$"
match=rg.Search(me.SelText)
if match <> nil then
imgsrc= match.SubExpressionString(1)
else
MsgBox "Try reselecting, and include start and end tags."
end
else
rg.SearchPattern="<img src="+chr(34)+"(\w+\.\w+)"+chr(34)+">$"
match=rg.Search(me.SelText)
if match <> nil then
imgsrc= match.SubExpressionString(1)
else
MsgBox "Try reselecting, and include start and end tags."
end
end
f = getFolderItem(imgsrc)
if f <> nil then
picturev.Backdrop = f.OpenAsPicture
end if
picturev.Show
end

This code is stuck in the SelChange event for an EditField control. When the control key is down and the left hand side of the selection is "<img src=", the image is determined and displayed. If a full URL is used, indicated by "/", then a regular expression that assumes a URL pulls out the image file name from the end of the URL, otherwise, a regular expression that assumes it is just a plain reference to a local file is used. The idea is that the entries in the journal can refer to either local images or images on the web. If the image is stored on the web, the HTML version of the journal viewer can see the image via a browser. By then copying that image locally, the built-in image viewer of the journal can also view it. I'm sure there is a fancier regular expression that will account for both cases, but it was easier to use if in this case, as the regular expression wasn't apparent.




Please read our Terms of Use
Microsoft, Windows, Windows XP, Windows 2003, Windows 2000, and NT are either trademarks or registered trademarks of Microsoft Corporation. NetAdminTools.com is not affiliated with Microsoft Corporation. Linux is a registered trademark of Linus Torvalds, and refers to the Linux kernel. The operating system of most distributions that contain the Linux kernel is GNU/Linux. All logos and trademarks in this site are property of their respective owner. Copyright 1997-2008 NetAdminTools.com

Created by:
MCJ
MCJ CMS