Search Array of String for exact match words
I need to create a search feature.
There will be a textfield where the user will input a word or words.
Then I need to check if the are any reference in the array of names.
namesArray ["ocean in the sky", "cean on sky", "cean is white"];
keywordsArray ["cean", "sky"];
matchCounter = 0;
If I input the word "cean" I dont want in my results "ocean in the sky", only "cean is sky".
I have the following code:
for (var j:int = 0; j < namesArray.length; ++j)
var tempStr:String = namesArray[j];
for (var k:int = 0; k < keywordsArray.length; ++k)
if (tempStr.indexOf(arrayKeywords[k]) != -1)
matchCounter++;
if(lengthKeywords == matchCounter)
trace("yeahhh... there's a match!!");
matchCounter = 0;
Is there a better way? How can I do this?
There are few things but the main problem is that "new RegExp()" needs double escapes ("\\")
var namesArray:Array = ["ocean in the sky", "cean on sky", "cean is white"];
var keywordsArray:Array = ["cean", "sky"];
for (var j:int = 0; j < namesArray.length; j++){
var matchCounter:uint = 0;
var tempStr:String = namesArray[j];
for (var k:int = 0; k < keywordsArray.length; k++){
var regExp:RegExp = new RegExp("(\\s+|^)" + keywordsArray[k] + "(\\s+|$)");
if (tempStr.search(regExp) > -1){
matchCounter++;
if(keywordsArray.length == matchCounter){
trace("\"" + namesArray[j] + "\" matched all the keywords");
Traces:
"cean on sky" matched all the keywords
Similar Messages
-
Search MS Word for Exact Match
I've got a script that opens an MS Word document, then searches through a directory for each image file (.jpg), then does a find and replace using the filename as the search string, and inserts the image in place of the text it finds. My problem is that
it's not doing an exact match. This means for example that if it looks for image1.jpg and that text exists in the word document inserts the image in it's place (the text being a placeholder). But if mimimage1.jpg was in place before it then it would insert
the .jpg there - not doing an exact match.
Here's the code I've got so far:
# Get variables from XML file
$MyDir = Split-Path $MyInvocation.MyCommand.Definition
# Get settings from variables.xml.
[xml]$settings = get-content "$MyDir\variables-test.xml"
# Assign the settings to local variables.
$SMTP = $settings.Settings.Setting.SMTP
$port = $settings.Settings.Setting.port
$from = $settings.Settings.Setting.EmailFrom
$to = $settings.Settings.Setting.EmailTo
$subject = $settings.Settings.Setting.Subject
$body = $settings.Settings.Setting.Body
$savepath = $settings.Settings.Setting.SavePath
$docfile = $settings.Settings.Setting.WordDoc
$XMLpath = "$MyDir\variables.xml"
[String[]]$strXML=@()
[xml]$xml = get-content $XMLpath
$parse_results = New-Object System.Collections.ArrayList
add-type -AssemblyName "Microsoft.Office.Interop.Word"
$wdunits = "Microsoft.Office.Interop.Word.wdunits" -as [type]
$application = New-Object -comobject word.application
$application.visible = $false
$document = $application.documents.open($docfile)
set-variable -name wdGoToLine -value 3 -option constant
set-variable -name wdGoToAbsolute -value 1 -option constant
# Create new directory
$date = (Get-Date -format "dd-MM-yyyy")
$newdir = $savepath + "archive" + "-" + $date
New-Item -ItemType directory -Path $newdir
# Search Word document for filename and insert image
foreach($file in Get-ChildItem $savepath -Filter *.jpg)
if ($application.Selection.Find.Text = $file)
if ($application.Selection.Find.Execute())
$insertfile = $savepath + $file
$objSelection = $application.selection
$objShape = $objSelection.InlineShapes.AddPicture($insertfile)
$gotoline = $objSelection.GoTo($wdGoToLine, $wdGoToAbsolute,1)
# Move spreadsheets and images to archive location and cleanup after dfm2xls.ps1 before ending script
foreach($movexlsx in Get-ChildItem $savepath -Filter *.xlsx)
$xlpath = $savepath + $movexlsx
Move-Item $xlpath $newdir
foreach($movejpg in Get-ChildItem $savepath -Filter *.jpg)
$imgpath = $savepath + $movejpg
Move-Item $imgpath $newdir
# Save document then close application
$newsave = $savepath + $date + "-report.docx"
$document.SaveAs([ref]$newsave)
$document.Close()
$application.quit()
At the moment it doesn't do an exact match but I've tried using:
$MatchWholeWord = $True
$MatchCase = $False
and then
$application.Selection.Find.Execute($MatchWholeWord, $MatchCase)
But that stopped it from finding any matches. Can anyone help?
Thanks in advanceHi AJ Mellor,
If you want to replace the words of the .jpg file's name with the picture in word file, this script should be helpful for you to modify your script:
Hey, Scripting Guy! How Can I Read Words in a Text File and Make Those Same Word Italic in a Word Document?
Insert pictures in a folder into a Word document (PowerShell)
In addition, to get the words of the file name instead of the full path name, please refer to the script below:
$files = Get-ChildItem $savepath -Filter *.jpg
$words = $files.basename
foreach($word in $words){
I hope this helps. -
ITunes 10 search for exact match or Boolean Searches
Is there a way to force an exact match when performing a search in iTunes?
I tried putting "" around my search and get no results.
The goal would be to search Artists for the artist "Hem", and only show results for only "Hem" and not both "Hem" and "Edie Brickel and the New Bohemians"
As far as I can tell there are no Boolean search options in here either.
iTunes 10.1 (54)Mad.Macs wrote:
Thanks,
I know Smart Playlists is a workaround for this, but that is about that is about 6 clicks plus typing to accomplish what could be done by simply typing in "hem" in the search field. If you use Smart Playlists for this, you would also need to go back and delete the playlist when you are done.
Yep, like I said I leave it there for next time....
I wonder why they would leave what is now a universally understood search option out of iTunes?
Who knows? Feature requests go to iTunes Feedback.
tt2 -
String of letters to 1-D Array of strings for spreadsheet
What I would like to do is be able to take this string as it is the A's and B's that are being generated as the program runs,
I would like to take this string and get it into file in delimited tabs just as the numbers are. If there is a created 1-D array of
strings that works, but that is controlled on the front panel, I would like to create this from data that is comming in. In other words
I am stuck on how to create a 1-D array of Sting from the string value comming in. I want to do this so that I can get all the different
values A's or B's into the different tab fields. As it is they are comming all up in the first column and not "tabbing" Please see the
attached file in the rows 5 an
d 7.
Thanks,
Brian
Attachments:
Array_of_strings_to_spreadsheet2.vi 28 KB
Turn_data1.xls 1 KBBrian
You need to convert your string to contain single tabs as separator. The problem is that your string is "dirty", i.e. it contains a variable amount of spaces to seperate the items. If you strictly had single space separators, you could just replace all spaces with tabs.
"Scan string for tokens" by default does not allow empty tokens, thus takes care of the multiple spaces.
The attached simplified code assumes a fixed number of items (12), if this is a variable, you need to use a while loop and sense the end of the input string. Let me know if this is clear.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
StringToArrayofstringsToSpreadsheetstring.vi 21 KB -
Open item Settlement for exact match.
Hi All,
We have requirement in our project to clear the exact match first ahead of the oldest due debt.
To elaborate on the requirement, please have a look at the following example.
1st Invoice -$100 Due date-1/11/2010
2nd Invoice-$250 Due date-1/12/2010
Customer makes a payment of $250 on 10/12/2010.
As per our requirement, It should clear the 2nd Invoice first, as it gets an exact match and not the oldest debt due.
However, if the customer makes a payment of say $300, then it does not find any exact match and hence will clear the oldest due first.In this case,the 1st invoice.
In the clearing Step under the clearing variant , we have tried to use the Amount rule as '0'-Clearing only possible when amounts are same.....but it is not working as per our requirement.
Can any one of you give any thoughts on the issue?
Thanks,
AmlanHi - tried this config, and I cleared an open item based on exact amount, that was due later that 2 other items. See below.
Ivor Martin
Clearing Var. ZEX Exact matching test
Clearing Step 1 Exact match on amount
Char. Grpng rule Sort charact. Rank Sort
1. 013 Open Amount Without In 1.
2. 2.
3. 3.
4. 4.
5. 5.
Amount Rule 0
Clearing rule Paymt rem. var. ZEX / 2
End of assgmt
/ 0
Clearing Step 2 Oldest due date
Char. Grpng rule Sort charact. Rank Sor
1. 015 Contract Account 1. 010 Due date
2. 2.
3. 3.
4. 4.
5. 5.
Amount Rule
Clearing rule Paymt rem. var. / 0
End of assgmt 9
/ 0 -
Array of String for input paramter + dynamic invocation
Does anybody know a place I can find an example of web service
using the following methods:
1. Array of String as input parameter
2. Client uses dynamic invocation
Specifically, 1. how do I define the parameter type in web-services.xml?
2. how do I refer to the type in a client code?
Thanks,
HongHello,
The doclitparam interop round 3 example does a echo string array.
http://dev2dev.bea.com/managed_content/direct/webservice/r3server.zip
Also there is a DII example in the WebService Wizard's archive:
http://dev2dev.bea.com/managed_content/direct/webservice/wswa.html#qz29
HTH,
Bruce
Hong wrote:
Does anybody know a place I can find an example of web service
using the following methods:
1. Array of String as input parameter
2. Client uses dynamic invocation
Specifically, 1. how do I define the parameter type in web-services.xml?
2. how do I refer to the type in a client code?
Thanks,
Hong -
Search for exact match without additional words
Hi everybody,
is it possible to find out if a tag contains a certain word or phrase and nothing else? E.g. the search for all documents with the title "foo" should match all documents containing <title>foo</title> but not documents that contain something like <title>foo bar</title>. I tried something like "( foo ~ ( % ~ foo ) ) WITHIN title" but I get a "wildcard query expansion resulted in too many terms" error, so using a wildcard is no option here. Any ideas?Another method would be to use extractvalue to limit the rows. It would still use the text index to get the rows with foo in it, then extractvalue would limit it to just those rows where only the word foo is in it. This would eliminate the need for a procedure or user_datastore or increasing the index size. Please see the demonstration below.
SCOTT@orcl_11gR2> create table documents
2 (text varchar2 (45))
3 /
Table created.
SCOTT@orcl_11gR2> insert all
2 into documents values ('<title>foo</title>')
3 into documents values ('<title>foo bar</title>')
4 into documents values ('<title>bar foo</title>')
5 select * from dual
6 /
3 rows created.
SCOTT@orcl_11gR2> insert into documents
2 select '<title>' || object_name || '</title>'
3 from all_objects
4 /
76012 rows created.
SCOTT@orcl_11gR2> create index test_idx
2 on documents (text)
3 indextype is ctxsys.context
4 parameters
5 ('section group ctxsys.auto_section_group')
6 /
Index created.
SCOTT@orcl_11gR2> set autotrace on explain
SCOTT@orcl_11gR2> select * from documents d
2 where contains (text, 'foo within title') > 0
3 and extractvalue (xmltype (d.text), '//title') = 'foo'
4 /
TEXT
<title>foo</title>
1 row selected.
Execution Plan
Plan hash value: 3102160860
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 36 | 10 (0)| 00:00:01 |
|* 1 | TABLE ACCESS BY INDEX ROWID| DOCUMENTS | 1 | 36 | 10 (0)| 00:00:01 |
|* 2 | DOMAIN INDEX | TEST_IDX | | | 4 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(EXTRACTVALUE("XMLTYPE"."XMLTYPE"("D"."TEXT"),'//title')='foo')
2 - access("CTXSYS"."CONTAINS"("TEXT",'foo within title')>0)
Note
- dynamic sampling used for this statement (level=2)
SCOTT@orcl_11gR2> -
I have a list of names in three columns - B2:B425, D2:406, & E2:30 where they were input by different people, so the names are worded differently. For example, I can have the name "Handler, Jones, & Wright" and someone else has the name
listed as "Handler Corp." What I need is to find a formula or VBA macro code that can search through my list and notice the possible duplicates and highlight them. Since they are all different names, I cannot give it a unique "text" to
search.
I found a code posted in this forum from some time ago (for two columns) but it highlighted all these names that had no partial words in common. Perhaps you can look over the code below and modify it for me or provide me with another one? Please let me know
if you need any further information to guide me.
Sub HighlightDups()
Dim rg1 As Range, rg2 As Range, c As Range, d As Range
Dim sTemp As String, sTempWords() As String, sTempDWords() As String
Dim re As Object, mc As Object
Dim i As Long, j As Long
Dim sFirstAddress As String
Set rg1 = Range("B2", Cells(Rows.Columns.Count, "B").End(xlUp))
Set rg2 = Range("D2", Cells(Rows.Columns.Count, "D").End(xlUp))
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.ignorecase = True
With Range(rg1, rg2)
.Font.Color = vbBlack
.Font.Bold = False
.Interior.Color = xlNone
.FormatConditions.Delete
End With
For Each c In rg1
re.Pattern = "\b\w+\b"
If re.test(c.Text) = True Then
Set mc = re.Execute(c.Text)
ReDim sTempWords(0 To mc.Count - 1)
For i = 0 To UBound(sTempWords)
sTempWords(i) = mc(i)
Next i
For i = 0 To UBound(sTempWords)
Set d = rg2.Find(What:=sTempWords(i), _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not d Is Nothing Then
re.Pattern = "\b" & sTempWords(i) & "\b"
sFirstAddress = d.Address
Do
If re.test(d.Text) Then
With c
.Font.Color = vbWhite
.Font.Bold = True
.Interior.Color = vbBlue
End With
With d
.Font.Color = vbWhite
.Font.Bold = True
.Interior.Color = vbBlue
End With
End If
Set d = rg2.FindNext(after:=d)
Loop While Not d Is Nothing And d.Address <> sFirstAddress
End If
Next i
End If
Next c
Set re = Nothing
End Sub
Programming/Code related questions should really be posed in one of the following forums
Excel for Developers
http://social.msdn.microsoft.com/Forums/en-US/exceldev
Microsoft Office Programming
http://answers.microsoft.com/en-us/office/forum/customize?page=1&tab=all&tm=1361680524815
Tony Chen
TechNet Community Support -
I started this question in an Adobe Reader forum, but am reposting here.
Within one pdf, I'm trying to find the locations where two words appear close to each other. The document is a manual of Structured Framemaker from Adobe. The words are "context" and "element" (I'm trying to find out what "context" means in EDD in Framemaker).
Using Advanced Search on Acrobat XI Professional, but the response is the same in Acrobat XI Reader, i.e. zero results.
Putting a comma between words doesn't change results.
Selecting either of these doesn't change results:
--Match Any of the words
--Match Exact word or phrase
Clicking on the Show More Options adds a Proximity box but I've been unable to make the box selectable (it's greyed out).
Although I'm only interested in the results of the one pdf, I was advised to select a whole folder. When I select a directory, additional options appear, but the Proximity button is still unselectable.
What turns ON the Proximity button?
Is there a way to change Acrobat default so that the More Options is always turned on?
Thanks in advance.Proximity will become available if you're using a index (Tools > Document Processing > Full Text Index with Catalog), which you can create with Acrobat Pro for just this single document if you place it in a folder by itself. You will also have to select "match all words" or whatever the exact wording is in the advanced seach panel.
-
Search filename contains - rather than exact match
What I want to do:
I want to be able to search from a paragraphed .txt file containing numbers only like this
1234567
1234568
1234569
1234570
In a specific folder like this
01 ADVERTS < Folder
Sub folders:
01 Billy 1234567
01 Graham 1234568
01 Sue 1234569
01 Paul 1234570
But at the moment it cannot find anything.
The only way I can get this to work is if I rename all the Sub folder names to match exactly what the paragrahped numbers are or vice versa but this is more work and counter productive.
Any help would be appreciated.
Thanks in advance.The following script should do what you are asking for:
set basePath to "old_hd:Users:Blan:Desktop:Last Week:ADS:01 Announcements:"
try
set destinationPath to alias "old_hd:Users:Blan:Desktop:This weeks:ADS:01 Announcements:"
on error
display alert "Folder Not Present"
return
end try
set fileList to paragraphs of (read alias "old_hd:Users:Blan:Desktop:01 Numbered List.txt")
set folderPaths to {}
repeat with thisFileName in fileList
if length of thisFileName > 0 then
try
tell application "Finder"
set theFolderName to name of (folder 1 of (basePath as alias) whose name ends with thisFileName)
end tell
copy (basePath & theFolderName) as alias to the end of folderPaths
on error
display alert "File “" & (basePath & thisFileName) & "” does not exist. Skip this file or cancel script?" buttons {"Skip File", "Cancel"} default button "Skip File"
if button returned of the result is "Cancel" then return
end try
end if
end repeat
tell application "Finder"
duplicate folderPaths to destinationPath
end tell
Hope it can help.
Message was edited by: Pierre L. (removed “space & ”) -
Selecting DAQ channels by arrays of strings for scxi 1102/4c
Hello,
I have an urgent matter - for my project I have to modify DAQ analog acquisition on several machines. The existent applications use definitions of virtual channels AnCh0-63, and they select them by DAQ constants which are connected to AI Acquire Waveforms. Now I need to make one program for all machines (different slot numbers of the cards) that will retrieve channel selection from a database (LV 7.1, MS SQL Server 2005).
Is there a way to directly use the DAQ constants by feeding them strings from the database? The catch is that the company wishes to keep the existent programs and use a database for storing and loading parameters. Otherwise I tried with global-channel definition strings (obx!scy!mdz!0,2,...,n) but there were problems with some combinations of channels.
Thanks in advance!
simonHello Simon,
If I am understanding the question, you want to use the same program
you have been using (which uses our "legacy" driver, Traditional DAQ)
and want to integrate that into a database system. The trick seems to
be inputting the various inputs into the AI Aquire Waveforms directly
from strings you have aquired from your database.
If my understanding is correct, then we want to convert strings into
the data types required by the VI. The channels input can be fed a
string directly (as long as it is in the format it expects), while the
other inputs require numeric values. You can convert strings into
numerics with the Decimal String to Number VI (Functions
Palette»String»String/Number Conversion). Using these, you can then
input the correct inputs:
You can also parse strings with the string manipulation VIs (Functions Palette»String) if you need to. I hope this is the information you are looking for, your application sounds like it could save a lot of time in the long run.
Message Edited by Neal M on 11-28-2007 02:45 PM
Neal M.Applications Engineering National Instruments www.ni.com/support
Attachments:
TDAQString.JPG 10 KB -
How can I search an internet page for a certain word using Safari
Hello Everyone,
I am a recent user of Safari, having switched over from Firefox. On Firefox if you wanted to find a certain word on a internet page (on a PC, I am also a brand new Mac user), you would press Ctrl-F and enter the word. What is the procedure for this on Safari using a Mac?
Thank you very much for your time and response, I greatly appreciate it.Thank you Niel, another quick question.
When I used Firefox when I 'moused-over' a link the link's destination would pop-up in a small section at the bottom of the browser, does Safari have that ability? -
How to execute exact match & contains text search simultaneoulsy in Oracle 10g
Hi,
We have scenario where there are more than 50 million rows in a table with description column length as 1000 character. We have a web interface from where we generate a rule of comma separated keywords like
"Standard", Single, Cancel, "deal" & so on. The words in quotes needs to be checked for exact match & the one without quotes will be searched using contains.
The problem is that we can have a rule of such a combination as large as 4000 characters of inclusion & 2000 such characters for exclusion (not to consider the description under exclusion) and this search when run on the table with millions of rows does not work using oracle regular expression, but works with smaller no. of search keywords.
Is there a better way to do such a kind of search in Oracle or if not then outside oracle using any other tool
Thanks,
APPlease find below the table script, few insert statements along with the SP & function. Please help.
-- Create Table
CREATE TABLE Roomdescriptionmaster
ID long,
ROOMDESCRIPTION nvarchar2, --- max 1000 charaters
Createddate datetime
----- Insert statements
INSERT INTO ROOMDESCRIPTION (ID, ROOMDESCRIPTION, Createddate ) VALUES (1, 'Double Room (2 Adults + 2 Children) | FREE cancellation before Mar 16, 2014 PAY LATER All-Inclusive [ Included:10 % VAT] Meals:All meals and select beverages are included in the room rate.Cancellation:If canceled or modified up to 2 days before date of arrival,no fee will be charged.If canceled or modified later,100 percent of the first two nights will be charged.In case of no-show, the total price of the reservation will be charged. Prepayment:No deposit will be charged', sysdate)
INSERT INTO ROOMDESCRIPTION (ID, ROOMDESCRIPTION, Createddate ) VALUES (1, 'Double or Twin Room | FREE cancellation before Feb 1, 2014 PAY LATER All-Inclusive [ Included:10 % VAT] Meals:All meals and select beverages are included in the room rate.Cancellation:If canceled or modified up to 2 days before date of arrival,no fee will be charged.If canceled or modified later,100 percent of the first two nights will be charged.In case of no-show, the total price of the reservation will be charged. Prepayment:No deposit will be charged', sysdate)
INSERT INTO ROOMDESCRIPTION (ID, ROOMDESCRIPTION, Createddate ) VALUES (1, 'Quadruple Room (3 Adults + 1 Child) | FREE cancellation before Mar 16, 2014 PAY LATER Full board included [ Included:10 % VAT] Meals:Breakfast, lunch & dinner included.Cancellation:If canceled or modified up to 2 days before date of arrival,no fee will be charged.If canceled or modified later,100 percent of the first two nights will be charged.In case of no-show, the total price of the reservation will be charged. Prepayment:No deposit will be charged', sysdate)
INSERT INTO ROOMDESCRIPTION (ID, ROOMDESCRIPTION, Createddate ) VALUES (1, 'Triple Room with Lateral Sea View (2 Adults + 1 Child) | FREE cancellation before Dec 6, 2013 PAY LATER All-Inclusive [ Included:10 % VAT] Meals:All meals and select beverages are included in the room rate.Cancellation:If canceled or modified up to 2 days before date of arrival,no fee will be charged.If canceled or modified later,100 percent of the first two nights will be charged.In case of no-show, the total price of the reservation will be charged. Prepayment:No deposit will be charged', sysdate)
INSERT INTO ROOMDESCRIPTION (ID, ROOMDESCRIPTION, Createddate ) VALUES (1, 'Single Room with Lateral Sea View | FREE cancellation before Dec 6, 2013 PAY LATER All-Inclusive [ Included:10 % VAT] Meals:All meals and select beverages are included in the room rate.Cancellation:If canceled or modified up to 2 days before date of arrival,no fee will be charged.If canceled or modified later,100 percent of the first two nights will be charged.In case of no-show, the total price of the reservation will be charged. Prepayment:No deposit will be charged', sysdate)
--SP
CREATE OR REPLACE PROCEDURE
SP_PGHGETROOMDESCRIPTION(v_BId number,
v_DaysOfData integer,
v_Incl1 nvarchar2,
v_Incl2 nvarchar2,
v_Incl3 nvarchar2,
v_Excl1 nvarchar2,
v_CurrentIndex integer,
v_RecordPerPage integer,
v_IndexMultiplier integer,
ref_recordset out sys_refcursor
) as
start_index integer;
end_index integer;
Incl1 nvarchar2(2000);
Incl2 nvarchar2(2000);
Incl3 nvarchar2(2000);
Excl1 nvarchar2(2000);
v_desc_utf_value VARCHAR2(10);
begin
v_desc_utf_value:= 'utf8';
if v_incl1 is null or trim(v_incl1) = '' then
--dbms_output.put_line('include 1 is null or blank');
Incl1 := '';
else
Incl1 := lower(v_Incl1);
end if;
if v_incl2 is null or trim(v_incl2) = '' then
--dbms_output.put_line('include 2 is null or blank');
Incl2 := '';
else
Incl2 := lower(v_Incl2);
end if;
if v_incl3 is null or trim(v_incl3) = '' then
--dbms_output.put_line('include 3 is null or blank');
Incl3 := '';
else
Incl3 := lower(v_Incl3);
end if;
if v_Excl1 is null or trim(v_Excl1) = '' then
--dbms_output.put_line('Exclude 1 is null or blank');
Excl1 := '';
else
Excl1 := lower(v_Excl1);
end if;
-- Old code
-- and regexp_like(lower(ROOMDESCRIPTION), Incl1, 'i')
-- and regexp_like(lower(ROOMDESCRIPTION), Incl2, 'i')
-- and regexp_like(lower(ROOMDESCRIPTION), Incl3, 'i')
-- and not regexp_like(lower(ROOMDESCRIPTION), Excl1, 'i')
--- First call to SP
if v_CurrentIndex = 1 then
start_index := v_RecordPerPage * v_IndexMultiplier;
end_index := (v_CurrentIndex - 1 + v_IndexMultiplier) * v_RecordPerPage;
open ref_recordset for
select * from (
select ROOMDESCRIPTION, Createddate, rownum as rn
from roomdescriptionmaster
where BID = v_BId
and TO_NUMBER(trunc(sysdate) - to_date(to_char(createddate, 'yyyy-mm-dd'),'yyyy-mm-dd')) <= v_DaysOfData
and length(FN_GET_RESTRICTION(lower(ROOMDESCRIPTION),Incl1,Incl2,Incl3,Excl1,v_desc_utf_value)) > 0
and row_num <= v_RecordPerPage * v_IndexMultiplier
order by row_num;
else
--- Subsequent calls to SP using paging from UI
start_index := (v_CurrentIndex - 1) * v_RecordPerPage + 1;
end_index := (v_CurrentIndex - 1 + v_IndexMultiplier) * v_RecordPerPage;
open ref_recordset for
select * from (
select ROOMDESCRIPTION, Createddate, rownum as rn
from roomdescriptionmaster
where BID = v_BId
and TO_NUMBER(trunc(sysdate) - to_date(to_char(createddate, 'yyyy-mm-dd'),'yyyy-mm-dd')) <= v_DaysOfData
and length(FN_GET_RESTRICTION(lower(ROOMDESCRIPTION),Incl1,Incl2,Incl3,Excl1,v_desc_utf_value)) > 0
order by roomdescriptionmasterid desc
where rn >= start_index
and rn <= end_index
order by rn;
end if;
commit;
end SP_PGHGETROOMDESCRIPTION;
--Function
CREATE OR REPLACE FUNCTION FN_GET_RESTRICTION(
v_rate_description IN NVARCHAR2,
v_include_1 IN NVARCHAR2,
v_include_2 IN NVARCHAR2,
v_include_3 IN NVARCHAR2,
v_exclude IN NVARCHAR2, v_desc_utf_value IN VARCHAR2)
RETURN NVARCHAR2
IS
CURSOR include_1_cur IS
select regexp_substr(str, '[^,]+', 1, level) str
from (select v_include_1 str from dual)
connect by level <= length(str)-length(replace(str,','))+1;
CURSOR include_2_cur IS
select regexp_substr(str, '[^,]+', 1, level) str
from (select v_include_2 str from dual)
connect by level <= length(str)-length(replace(str,','))+1;
CURSOR include_3_cur IS
select regexp_substr(str, '[^,]+', 1, level) str
from (select v_include_3 str from dual)
connect by level <= length(str)-length(replace(str,','))+1;
CURSOR exclude_cur IS
select regexp_substr(str, '[^,]+', 1, level) str
from (select v_exclude str from dual)
connect by level <= length(str)-length(replace(str,','))+1;
include_1_rec include_1_cur%rowtype;
include_2_rec include_2_cur%rowtype;
include_3_rec include_3_cur%rowtype;
exclude_rec exclude_cur%rowtype;
tmp_var NVARCHAR2(200);
tmp_var_int NUMBER;
tmp_flag_int NUMBER;
return_str NVARCHAR2(200);
tmp_length NUMBER;
tmp_length_include_1 NUMBER;
tmp_length_include_2 NUMBER;
tmp_length_include_3 NUMBER;
tmp_length_exclude NUMBER;
tmp_regex_pattern VARCHAR2(1000);
flag_include_1_match INTEGER;
flag_include_2_match INTEGER;
flag_include_3_match INTEGER;
flag_exclude_match INTEGER;
BEGIN
tmp_length_include_1 := nvl(length(v_include_1),0);
tmp_length_include_2 := nvl(length(v_include_2),0);
tmp_length_include_3 := nvl(length(v_include_3),0);
tmp_length_exclude := nvl(length(v_exclude),0);
flag_include_1_match := 0;
flag_include_2_match := 0;
flag_include_3_match := 0;
flag_exclude_match := 0;
IF tmp_length_include_1>0 OR tmp_length_include_2 >0
OR tmp_length_include_3 >0 OR tmp_length_exclude >0 THEN
IF v_desc_utf_value ='utf8' THEN
----------------------------------------------------- UTF 8 STARTED --------------
----------------------------------------- INCLUDE 1
tmp_length := tmp_length_include_1;
IF tmp_length > 0 THEN
tmp_flag_int :=0;
FOR include_1_rec in include_1_cur
LOOP
tmp_var := trim('' || include_1_rec.str);
--dbms_output.put_line(tmp_var);
tmp_regex_pattern := '[^[:alnum:]]'||tmp_var||'[^[:alnum:]]|^'||tmp_var||'$|^'||tmp_var||'[^[:alnum:]]|[^[:alnum:]]'||tmp_var||'$';
tmp_var_int := nvl(regexp_instr(v_rate_description,tmp_regex_pattern,1,1),0);
IF (tmp_var_int <> 0) THEN
tmp_flag_int :=1;
flag_include_1_match := 1;
EXIT;
END IF;
END LOOP;
ELSE
flag_include_1_match := 1;
END IF;
-------------------------------------------- INCLUDE 2
tmp_length := tmp_length_include_2;
IF tmp_length > 0 THEN
tmp_flag_int :=0;
IF flag_include_1_match =1 THEN
FOR include_2_rec in include_2_cur
LOOP
tmp_var := trim('' || include_2_rec.str);
tmp_regex_pattern := '[^[:alnum:]]'||tmp_var||'[^[:alnum:]]|^'||tmp_var||'$|^'||tmp_var||'[^[:alnum:]]|[^[:alnum:]]'||tmp_var||'$';
tmp_var_int := nvl(regexp_instr(v_rate_description,tmp_regex_pattern,1,1),0);
IF (tmp_var_int <> 0) THEN
tmp_flag_int :=1;
flag_include_2_match := 1;
EXIT;
END IF;
END LOOP;
END IF;
ELSE
flag_include_2_match := 1;
END IF;
-------------------------------------------- INCLUDE 3
tmp_length := tmp_length_include_3;
IF tmp_length > 0 THEN
tmp_flag_int :=0;
IF flag_include_2_match =1 THEN
FOR include_3_rec in include_3_cur
LOOP
tmp_var := trim('' || include_3_rec.str);
tmp_regex_pattern := '[^[:alnum:]]'||tmp_var||'[^[:alnum:]]|^'||tmp_var||'$|^'||tmp_var||'[^[:alnum:]]|[^[:alnum:]]'||tmp_var||'$';
tmp_var_int := nvl(regexp_instr(v_rate_description,tmp_regex_pattern,1,1),0);
IF (tmp_var_int <> 0) THEN
tmp_flag_int :=1;
flag_include_3_match := 1;
EXIT;
END IF;
END LOOP;
END IF;
ELSE
flag_include_3_match := 1;
END IF;
-------------------------------------------- EXCLUDE
tmp_length := tmp_length_exclude;
IF tmp_length > 0 and flag_include_3_match =1 THEN
FOR exclude_rec in exclude_cur
LOOP
tmp_var := trim('' || exclude_rec.str);
tmp_regex_pattern := '[^[:alnum:]]'||tmp_var||'[^[:alnum:]]|^'||tmp_var||'$|^'||tmp_var||'[^[:alnum:]]|[^[:alnum:]]'||tmp_var||'$';
tmp_var_int := nvl(regexp_instr(v_rate_description,tmp_regex_pattern,1,1),0);
IF (tmp_var_int <> 0) THEN
tmp_flag_int := -1;
return_str := '';
EXIT;
END IF;
END LOOP;
END IF;
ELSE
----------------------------------------------------- UTF 16 STARTED --------------
----------------------------------------- INCLUDE 1
tmp_length := tmp_length_include_1;
IF tmp_length > 0 THEN
tmp_flag_int :=0;
FOR include_1_rec in include_1_cur
LOOP
tmp_var := trim('' || include_1_rec.str);
--dbms_output.put_line(tmp_var);
tmp_var_int := nvl(INSTR(v_rate_description,tmp_var,1,1),0);
IF (tmp_var_int <> 0) THEN
tmp_flag_int :=1;
flag_include_1_match := 1;
EXIT;
END IF;
END LOOP;
ELSE
flag_include_1_match := 1;
END IF;
-------------------------------------------- INCLUDE 2
tmp_length := tmp_length_include_2;
IF tmp_length > 0 THEN
tmp_flag_int :=0;
IF flag_include_1_match =1 THEN
FOR include_2_rec in include_2_cur
LOOP
tmp_var := trim('' || include_2_rec.str);
tmp_var_int := nvl(INSTR(v_rate_description,tmp_var,1,1),0);
IF (tmp_var_int <> 0) THEN
tmp_flag_int :=1;
flag_include_2_match := 1;
EXIT;
END IF;
END LOOP;
END IF;
ELSE
flag_include_2_match := 1;
END IF;
-------------------------------------------- INCLUDE 3
tmp_length := tmp_length_include_3;
IF tmp_length > 0 THEN
tmp_flag_int :=0;
IF flag_include_2_match =1 THEN
FOR include_3_rec in include_3_cur
LOOP
tmp_var := trim('' || include_3_rec.str);
tmp_var_int := nvl(INSTR(v_rate_description,tmp_var,1,1),0);
IF (tmp_var_int <> 0) THEN
tmp_flag_int :=1;
flag_include_3_match := 1;
EXIT;
END IF;
END LOOP;
END IF;
ELSE
flag_include_3_match := 1;
END IF;
-------------------------------------------- EXCLUDE
tmp_length := tmp_length_exclude;
IF tmp_length > 0 and flag_include_3_match =1 THEN
FOR exclude_rec in exclude_cur
LOOP
tmp_var := trim('' || exclude_rec.str);
tmp_var_int := nvl(INSTR(v_rate_description,tmp_var,1,1),0);
IF (tmp_var_int <> 0) THEN
tmp_flag_int := -1;
return_str := '';
EXIT;
END IF;
END LOOP;
END IF;
END IF;
IF tmp_flag_int = 1 THEN
return_str := 'truely matched';
ELSE
return_str := '';
END IF;
ELSE
return_str := '';
END IF;
return return_str;
EXCEPTION
WHEN OTHERS THEN
--dbms_output.put_line('Exception');
RAISE;
END FN_GET_RESTRICTION; -
What function searches a string for a phrase?
I'm looking for an AS3 phrase that searches a text string for a given search term, and then returns a certain numerical value if that phrase is found.
How would I go about doing this? Is there a built-in function for this?
I'm a nube and all help is appreciated.
Thanks,
MichaelindexOf or search(), depending on how exact the string is that you're trying to match. If it's exact, use indexOf. If it's a little "fuzzy," use search with a regular expression.
-
I am wanting to exactly match two ID numbers from two worksheets within the one work book. ID numbers are non linear. Once exactly matched I wish to retrieve a corresponding row value from worksheet two and have it appear in worksheet one against the correct ID number. I have been looking at IF, VLOOKUP, and MATCH functions and suspect that what I want to do requires a combination of two or more. Any help will be greatly appreciated.
regards VaughanhVaughan,
Data A:D is all cells start at column A thru column D.
There is built-in help using the menu item "View > Show Function Browser" in the search field (top right) you can enter vlookup and you will see the detailed description.
From this we see:
VLOOKUP
(search-for, columns-range, return-column, close-match)
search-for: The value to find. search-value can contain any value type.
columns-range: A range of cells. range is a reference to a single range of cells, which may contain values of any type.
return-column: A number that specifies the relative column number of the cell from which to return the value. return-column is a number value. The leftmost column in the range is column 1.
close-match: An optional value that determines whether an exact match is required.
close match (TRUE, 1, or omitted): If there’s no exact match, select the column with the largest top-row value that is less than the search value. Wildcards can’t be used in search-for.
exact match (FALSE or 0): If there’s no exact match, return an error. Wildcards can be used in search-for.
So... the 2,0 means return the value form the same row as the lookup value but from the 2nd column of the range. 3, 0 means from the 3rd column. the ", 0" means exact match
Maybe you are looking for
-
Mac Pro does not connect to ADSL router
Took my mac in so that they could install airport extreme card. When clicking on the Airport icon on task bar my router is listed in the drop down menu. When selecting it, it asks for a WPA password, after entering the password it shows the connectio
-
Dynamic Sql Using Execute Immediate
I am trying to construct a dynamic statement that takes in a supplied column name (COL_NAME), then do an Update on the column based on a supplied username. The table myTable has 4 columns and I would like to update a column thats supplied each time.
-
Service Tax Detail while recording a purchase invoice from T-Code F-43
Dear Sir, I am passing a Professional Fees Invoice, where in service tax is being charged, through T-Code F-43 Kindly let me know the following. 1. Where do I store the vendor's service tax registration detail? 2. Where do I store the service categor
-
Updating a shared report?
In Discoverer Desktop, is there a way for a user who is NOT the owner of a shared report to modify it and save the updated version over the original? I have a group of users who want to all be able to access and update a single report, but it's cumbe
-
Sort function in iTunes store?
iTunes 11 upgrade (Mac OS) results in a revised interface for the Store. On my system, it apparently no longer allows the user to sort a list of results by Artist, Albumn, Popularity, etc. The column headers are still there, but they are inert. Is th