Scan textfield for keyword and apply formatting

I was interested in searching through text in a textfield, and applying text formatting to keywords. For example, every time the word 'the' appears, apply a text format that changes it to green and 14pt. Here is an example of a format and text applied to a textfield. How would I go about searching through the textfield and applying this format only to specific words?
my_txt.text = 'The cat jumped over the house.'
/// my format I want to apply
with (_lt_fmt) {
                align = 'left';
                blockIndent = 0;
                bold = false;
                bullet = false;
                color = _green;
                font = FontNames.ARIAL;
                indent = 0;
                italic = false;
                kerning = false;
                leading = 0;
                leftMargin = 0;
                letterSpacing = 0;
                rightMargin = 0;
                size = 14;
                tabStops = [];
                target = "";
                underline = false;
                url = "";

" I replaced some var names b/c they were reserved words"
There were no reserved words for the current or application scope.
"How can I keep all the words highlighted in the different formats?"
Comment out this line:
main_txt.setTextFormat(main_txt.defaultTextFormat);
Also, the code you showed is too verbose. You can combine declarations and and instantiation in one place and have 5 lines instead of 10:
var highLightFormat0:TextFormat = new TextFormat("Arial",14,0xff00ff,"bold");
var highLightFormat1:TextFormat = new TextFormat("Arial",7,0xff0000,"bold");
var highLightFormat2:TextFormat = new TextFormat("Arial",9,0xCCCCCC,"bold");
var highLightFormat3:TextFormat = new TextFormat("Arial", 8, 0xffEE00, "bold");
var main_txt:TextField = new TextField();
In addition, function  getTxtFmt and the way you deal with getting TExtFormats is an ovekill - conditionals are worse than direct references. So, I suggest your code is:
import flash.text.TextFormat;
// keywords to highlight
var wordsToSearch:Vector.<String> = new <String>['the','interested','text', 'applying'];
// TxtFormats
var highLightFormats:Vector.<TextFormat> = new <TextFormat>[new TextFormat("Arial", 14, 0xff00ff, "bold"), new TextFormat("Arial", 7, 0xff0000, "bold"), new TextFormat("Arial", 9, 0xCCCCCC, "bold"), new TextFormat("Arial", 8, 0xffEE00, "bold")];
// Create TextField and add to display list
var main_txt:TextField = new TextField();
with (main_txt) {
     multiline = main_txt.wordWrap = true;
     autoSize = "left";
     width = 400;
     defaultTextFormat = new TextFormat("Arial",12);
     x = main_txt.y = 20;
     text = "I was interested in searching through text in a textfield, and applying text formatting to keywords. For example, every time the word 'the' appears, apply a text format that changes it to green and 14pt. Here is an example of a format and text applied to a textfield. How would I go about searching through the textfield and applying this format only to specific words?";
addChild(main_txt);
// Iterate through Vector of keywords
for (var i:int; i < wordsToSearch.length; i++){
     search(wordsToSearch[i], i);
// find whole words
function search(keyword:String, fmtChoice:int):void {
     //main_txt.setTextFormat(main_txt.defaultTextFormat);
     var txt:String = main_txt.text;
     var pattern:RegExp = new RegExp("\(\?\<\=\\s)" + keyword + "\\s","ig");
     var theResult:Object = pattern.exec(txt);
     while (theResult) {
          main_txt.setTextFormat( highLightFormats[fmtChoice], theResult.index, theResult.index + keyword.length);
          theResult = pattern.exec(txt);

Similar Messages

  • I have scanned about 1600 pages of 100-year old documents and saved them as pdf files.  I would like to search them for keywords and phrases.  Can anyone recommend software that can be used as an index for these documents?

    I have scanned about 1600 pages of 100-year old documents and saved them as pdf files.  I would like to search them for keywords and phrases.  Can anyone recommend software that can be used as an index or search engine for these documents?

    If you have Adobe Acrobat (not Adobe Reader) the program can perform an OCR on the document you acquired.
    In the past I used ABBYY FineReader

  • Scanning computer for music and move to itunes

    Recently upgraded to Windows 7 and person helping me moved all my music to an external drive.  Now want to get back into Itunes but playlists are gone and music is not organized.  How do I get itunes to look for music and import to itunes - or should I just stick with Windows media player?

    EDIT: I found a way around it.

  • Information broadcasting in 2004s for pdf and HTML format throws error

    hi experts,
    I am broadcasting via e-mail, when i use output format as MHTML or XML it works fine, when i change the output format to pdf or html (as zip file) i get the following errors
    <b>For PDF</b>
    --><b><i>Settings ZTEST1 were started from the BEx Broadcaster  </i></b>
            --><b><i>Processing for user BSHKSC, language EN  </i></b>
                    --><b><i>Processing setting ZTEST1</i></b>  
                              Error: com.sap.ip.bi.base.exception.BIBaseRuntimeException 
                              Error occurred during processing of framework class
                              CL_RSRD_PRODUCER_PRECALC, type PROD  
    <i><b>FOR HTML</b></i>
    --><i><b>Settings ZTEST1 were started from the BEx Broadcaster</b></i>  
           --><i><b>Processing for user BSHKSC, language EN </b></i> 
                 --><i><b>Processing setting ZTEST1</b></i>  
                     Web template 0BROADCAST_INDEX_PAGE could not be intstantiated
                      Error occurred during processing of framework class 
                      CL_RSRD_PRODUCER_PRECALC, type PROD
    Anyhelp will be really appreciated

    Hi Guus,
    We are not using the new authorizations we are still  on 3.5 authorization and we tried for an user with SAP_ALL, SAP_NEW authorization , so i am not sure if this is an authorization problem.
    We have a new issue on hand, initially i was able to broadcast thru xml,mhtml, xml formats, yesterday our portal was down, when the portal was brought up, i found that even the ones that were working were  now throwing an error.
    I spoke with the basis person, and he told me user mappings were lost, but even after restoring the user mapping were restored we still have the problem.
    If this error is caused by lack of new authorization, atleast we know what we are dealing with, but for now iam not sure if this error is due to authorization or some settings on the web server side.
    Message was edited by:
            shiva k

  • WS12300111 - Creating different title for Cancel and Apply for leave

    Hi Experts,
    Is there a way to change the existing workflow to be able to differentiate between approval and cancelling of leave request?
    Best regards,
    Brian

    Hi Umesh,
    The node that you are pointing to is for customizing type of absence, in business process it is called Absence Type which in HR translated to Subtype for infotype 2001. In ITS version, you can customized this table to launch different Absence (e.g. Annual leave, Bank Holiday, Maternity Leave, etc) to launch different workflow.
    For my case, the employee has already submitted the leave request, and decided to cancel the leave which has already been apply.
    In Workflow it will be easy if this 2 process generates 2 different events, but in ECC6 environment of the ESS it does not generate events but calling a standard workflow as stated in this thread topic.
    Best regards,
    Brian

  • Smartfroms for portrait and landscape format

    Hi Experts,
    can we able to create a form in two different format (Portrait and landscape) in a smartform. If any one have idea, Please assist me on the issue? if we can, can we able to extend secondary window for next page or not?
    Appreciate your aid in advance.
    Ram.

    Hi Sharin,
    Thank you for your response.
    yes, you right we can use both formats (portrait and land scape) in one smartform. But, here my probelm is when i use two main windows with difrerent main window size (width), the SAP system is not accepting. and even the page break also not working in secondary window.
    I want to display some number of forms with different format (say portrait and land scape). In this case the main window size is different. so how we can achieve solution for this issue.
    if you have any idea, please share with me.
    Thanks for your reply in advance.
    Ram.

  • Oracle 10.2 client for linux  and applying the new October Critical patch

    We are using the Oracle 10.2 client on one of our linux workstations.
    I can not find out if this new oracle critical patch October 05 needs to be applied to
    this client. Also, does anyone know if the Oracle 10.2 client already includes the patch updates for the alert 68 patchset? Our Oracle Sever runs on a solaris operating system which will be updated with the new critical October patch, but
    the linux client runs on a separate workstation.
    Thanks,
    Dave

    See my response to this posting.
    Oracle Security Patches

  • Disk Utility - Scan Image for Restore - Freeze

    I backed up my wife's iBook by starting her computer in target disk to my iBook which has a huge external attached. After about an hour, the image process was complete. Apple disk utility help says next to scan image for restore (not too sure why because I'm not restoring anything unless her drive dies). I begin the scan image for restore and get the progress bar that never shows and progress. Just keeps spinning/scanning for hours and I have no option to shut if off. Can't move external to trash because it in use, etc.
    Does this mean the original disk image may be bad? Do over?
    I'm using Disk Image as a solution for a total disk backup if a drive fails. No messing around with reconfiguring apps, etc. (i.e. plug and play) Is this the best way to do this?
    I come from the Mac Plus days. Hopefully I can contribute to the new OS discussions at some point. Thank you much!

    What format is the external drive?
    Is it Firewire or USB?
    Does the external drive have one of those front button touch things, like a My Book?
    I'm using Disk Image as a solution for a total disk backup if a drive fails. No messing around with reconfiguring apps, etc. (i.e. plug and play) Is this the best way to do this?
    I prefer a Clone myself.
    Get carbon copy cloner to make an exact copy of your old HD to the New one...
    http://www.bombich.com/software/ccc.html
    SuperDuper...
    http://www.shirt-pocket.com/SuperDuper/
    Have a look at Synchronize! Pro X 6.0.5
    http://www.macupdate.com/info.php/id/6897/synchronize!-pro-x
    Or the most expensive one & my favorite, ...
    http://www.tri-edre.com/english/tribackup.html
    Does this mean the original disk image may be bad? Do over?
    It can take quite awhile, and the progress bar isn't accurate at all, but it sounds like something is wrong.

  • Adding keywords and description to filename

    I've built myself an online gallery system to let my clients view and purchase their photos online.  To streamline my workflow, the script that imports my photos and resizes them for web display will also parse the file name to pull out a description and tags (keywords).  So I went in and added descriptions and keywords to a few test images and went to save them out to try running through the script, but when trying to save from Camera Raw neither keywords nor description were available to add to the jpg file name.  I figured I could get around this by simply using Bridge to rename the NEF files using the keywords and description, then I could just have CR save the jpgs using the current filename, but even Bridge doesn't seem to be able to access this metadata (and this would add addition time to the process anyway).
    I know I can work around this by simply batch renaming the sets of files that I would otherwise add this metadata to, and creating the file names manually before export, but that would add a fair amount of time into the process and eliminates me being able to use keywords in Bridge.  I work two jobs right now and anything I can do to my workflow to shave precious minutes off of it is huge to me.
    So I guess my questions are:
    1) Is it possible to get keywords and the description into my filenames (without spending more time than this process was designed to save)?
    2) If not, what's the point of having that metadata?
    3) Is this functionality available in a newer version of PS?
    I'm using Photoshop CS3 and the format my final JPG files need to have is: "[4 digit sequence number]_[Description]_[comma delimited keyword list].jpg"
    Thanks for reading, and hopefully helping. 

    Sorry about that, was too early in the morning when i posted that. No, you can't use Batch Rename to add keywords to files, i was thinking about metadata in general. The point of keywords is that you can search images for keywords and you can also use the Filter panel to show only images that contain certain keywords.
    If you want Bridge to have this functionality then i suggest that you make a feature request here: http://www.adobe.com/go/wish

  • Hierarchical keywords and Image Info Toolkit question

    I presently use Image Info Toolkit with a controlled vocabulary for keywording and I'm trying to find a way of doing the same thing in Aperture. Here's my present keyword setup:
    IIT works by having a cascading set of keyword windows. You can drill down to the desired level of detail, then apply the entire 'tree' to an image by drag and drop eg.
    Europe > UK > England > North Yorkshire > Whitby.
    All of the words are applied to the IPTC, plus you can assign synonyms EG Europe, EU, EEC.
    I've seen in my demo version of Aperture the ability to create the cascading set of keywords, but it doesn't seem to apply all of the branch, just the bottom word. I see the others are greyed out. Does this mean they are not embedded, or would they be applied on any exported images, say for stock library submissions?
    I'm pretty impressed with my demo version so far and if I can get a workflow I like, I can see me scrapping IIT and Bridge.
    AAny suggestions very welcome.
    Regards
    Neill Watson
    PowerMac G5 and Powerbook G4   Mac OS X (10.4.7)  
    PowerMac G5 and Powerbook G4   Mac OS X (10.4.5)  

    Hi this might help;
    http://homepage.mac.com/bagelturf/aparticles/metadata/keyhigh/keyhigh.html

  • Searching files for keywords

    Hi all,
    I am in the process of building a shell script as part of a auditing utility. It will search a specified directory for keywords and output results of the file path, and line number that the word was found on. I built a test script (shown below) that does just this, but egrep apparently does not allow MS word, excel, etc... documents to be read. I was wondering if someone could point me in an alternate direction that would allow me to search these types of documents as well? (Wordfile is a file that is create elsewhere with a list of words to search for e.g. bus)
    Thanks!
    cat << EOF > ${TMPDIR}/scanit
    rm -f ${TMPDIR}/strings
    strings "\$1" | egrep -n -i -f ${TMPDIR}/wordlist >> ${TMPDIR}/strings
    if [ -s ${TMPDIR}/strings ]
    then
    echo >> ${TMPDIR}/${HOSTNAME}.o
    echo "File: \$1" >> ${TMPDIR}/${HOSTNAME}.o
    file "\$1" >> ${TMPDIR}/${HOSTNAME}.o
    cat ${TMPDIR}/strings >> ${TMPDIR}/${HOSTNAME}.o
    fi
    rm -f ${TMPDIR}/strings
    EOF
    HOSTNAME=`hostname`
    export HOSTNHAME
    if [ $# -eq 0 ]
    then
    echo "You must specify the start of the directory tree to search"
    exit
    fi
    find $1 -type f 2> ${TMPDIR}/${HOSTNAME}finderrors | tee ${TMPDIR}/${HOSTNAME}_filelist | \
    head -100 |\
    sed -e "s^sh -x ${TMPDIR}/scanit \"+" -e 's/$/"/' > ${TMPDIR}/scanitnow
    sh -x ${TMPDIR}/scanitnow 1> ${TMPDIR}/${HOSTNAME}scanrun 2>&1
    cd ${TMPDIR}
    if [ -s ${HOSTNAME}.o ]
    then
    date "+%Y%M%d_%H:%m:%S: indicators found on ${HOSTNAME}" > ${HOSTNAME}scanresults.csv
    cat ${HOSTNAME}.o >> ${HOSTNAME}scanresults.csv
    else
    date "+%Y%M%d_%H:%m:%S: No indicators found on ${HOSTNAME}" > ${HOSTNAME}scanresults.csv
    fi
    zip ${HOSTNAME}_scan.zip ${HOSTNAME}finderrors ${HOSTNAME}_filelist ${HOSTNAME}scanrun ${HOSTNAME}scanresults.csv

    I don't think that info is included in metadata (though I could be wrong - checkout Query Programming and Metadata attributes). If line numbers are a key part of this, then you're probably going to have to (a) make a quick conversion of office files to plain text using textutil, or (b) use osascript to search Word via applescript. trying to read a word doc as plain text in unix is going to give you mounds of headaches (particularly if the 'fast save' option is on in Office, since that will save changes non-sequentially on disk).

  • How to access custom property for attribute and control in .vm file?

    Hi,
    I have created custom properties in OPM for attribute and apply also that properties to attribute.
    But if how to access that value in .vm file?
    I accessed using
    $attribute.getProperty("ScreenProp", "default value")
    but it's not working but same is worked for screen custom property

    $control.getProperties().get("PropertyName") works for custom properties on a control
    If you output $control and $control.getProperties() to the html you can lookup the API for the used classes.
    I can't give an example of the html because it's stripped in this forum
    Edited by: Peter van de Riet on 20-mei-2011 14:18

  • ACCOUNTING FOR ACTUAL AND ESTIMATED OVERHEADs

    Hi
    I have some basic questions about the accounting flow for actual and applied OVERHEADs in SAP,
    When I receive the goods from production I credit Cost Of Goods Manufactured (Mat CostOHProcess Cost+ Prod Cost)
    1. How does the accounting entry flow in the above case.
    2. How do we provide for these expenses in advance or do we need to pass a JV (Provision/Payable a/cs)
    3. When the actual costs are booked, how do we book the same in Finance,  as we have already inventorised the estimated expenses.
    Thanks & Regards

    Eduardo,
    you don't HAVE to create a new cube, as Ravi says you could use the Actual cube, make it Real time and keep on switching the cube behavior between loading and planning.
    However what I would do is create a real time cube as a copy of the actual one. Build a multiprovider with exactly the same structure and an aggregation level on top of the multiprovider. The old plan data can remain in the Actual cube and using the layouts and planning functions you can use it without a problems.
    Then all the new planning data should be written to the new cube.
    This way, once the old plan data becomes obsolete your data will be partitioned in two cubes, with the advantage of reporting using a multiprovider.
    Regards,
    C

  • "Scan String For Tokens" weird behaviour

    I am trying to carry out the simple task of getting a string with
    comma delimiters and produce a string_array with the values in between
    the commas; this would simplify calling the different parts of the
    string.
    Example:
    INPUT: this,is,an,example
    OUTPUT: this|is|an|example (this would be an array of strings)
    Using a while loop with the two VI "Scan String For Tokens" and
    "Insert to array" should be enough to carry this task. I started
    using a FOR loop as the number of tokens I´ll be using is fixed.
    However I wanted to make the subVI more general by allowing any
    #tokens in the input string and using the token index with a WHILE
    loop to do this. The "token index" output from the "Scan String For
    Tokens" is said to be use
    d in a while loop to process the whole
    string.
    However,I´m getting -1 as an output even if I´ve got more tokens left
    and the while loop therefore exits.
    What am I doing wrong?
    Should I use -2 as the comparison to decide whether I´m at hte end or
    not of the string?
    Cheers and TIA

    Check the offset for -1, not the token index. (See attached image). If course if this is a multiline string, the you also need /n etc as delimiter.
    If the string ends in a delimiter, you need to clip the last array element. I usually use "reshape array" with the output from [n] as input.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ScanForTokens.gif ‏17 KB

  • Delimiteddata and number format mask

    Hi,
    I need to export data from my report to a csv format in reports 6i.
    I installed patch 12 so I can use the delimiteddata format.
    This works but I do have problems with the number format.
    I formatted all of the number fields so they appear as desired in the report when running in C/S mode.
    I learned that you can use the number format, date format and cell wrapper variables for delimited and delimiteddata formats.
    These parameters do work with delimited output but they don't when generating delimiteddata.
    Only when I start the reports builder with numberformatmask=something on the command line then the number format given on the command line will be used. but then you cannot change it (even not in the dialog when generating a delimited format) anymore once reports builder is open.
    Is there a solution for this problem or is it fixed in a later patch (I haven't seen anything new in then patch 13 notes).
    Piet

    Hi Pieter,
    This does looks like a Bug. Please contact Oracle Support to assist you in getting the right patch or otherwise.
    Regards
    Oracle Reports Team.

Maybe you are looking for