How to search for pages with titles starting with a specific phrase? - confluence-rest-api

I'm a little confused as to how I'm supposed to put together the CQL search. Basically, I want to grab all pages that have titles starting with a specific set of strings in that specific order. Example:
Searching for "Test Page" should return:
Test Page
Test Page (1)
Test Page Again
It should NOT return:
Test
Page
Page Test
(1) Test Page
Again Test Page
I tried many searches, like:
title = "Test Page*"
title ~ "Test Page*"
title ~ "Test" AND title ~ "Page*"
But none of them match exactly what I need. What do I need to change to match the start of a title only?
Alternatively, if it's not possible to search for words at the start of a title, I'd be happy if I can just search something like "Test Page (*)", where * would match any character. Then it should return this:
Test Page (1)
Test Page (2)
But not this:
Test Page
Test Page Again
Test
Page
Page Test
(1) Test Page
Again Test Page

For CQL searches that contain an exact string or phrase, you should use the CONTAINS operator and surround the phrase with double quotes as you do in your second example:
title ~ "Test Page*"
CQL also supports the single character wildcard search symbol (?), so for the 'alternate' search you requested, the form should be:
title = "Test Page(?)"
While regular expressions syntax is allowed between back-slashes, I don't see any evidence that there can be selection by beginning (^) or end ($) of the element. However, using the EQULAS operator with the multi-character wildcard should give the same result:
title = "Test Page*"
So, according to all available documentation, including documentation for Apache Lucene upon which CQL is based, you are doing it right. You state that
'none of them match exactly what I need.'
Could you provide more information about why these queries were not correct?

Related

Regex to find a specific anchor tag that have href with a specific domain and nofollow

I have a string that contains html I want a regex that get me the string that has with a specific domain name and has noFollow
I have found this would will do work on the domain name but does not include nofollow condition
(<a\s*(?!.\brel=)[^>])(href="https?://)((?stackoverflow)[^"]+)"([^>]*)>
let's say the domain name I want is stackoverflow
Example:
- "click here " this would match
- "<a href="stackoverflow.com"> would not match since it has no follow
- "<a href="google.com" rel = "nofollow"> would not match
It's bit hard to match a HTML tag with specific condition, but the following regex should do it:
select regexp_match(str, '<a((?:\s+(([^\/=''"<>\s]+)(=((''[^'']*'')|("[^"]*")|([^\s<>''"=`]+)))?)))* href=((''(https?:\/\/)?stackoverflow\.com[^'']*'')|("(https?:\/\/)?stackoverflow\.com[^"]*"))((?: (([^\/=''"<>\s]+)(=((''[^'']*'')|("[^"]*")|([^\s<>''"=`]+)))?)))*\s+rel=("nofollow"|''nofollow'')((?: (([^\/=''"<>\s]+)(=((''[^'']*'')|("[^"]*")|([^\s<>''"=`]+)))?)))*\/?>') from tes;
It's really hard to read, but basically most of the regex is there for matching attributes. The important thing for you is to find stackoverflow\.com (which can be found 2 times; one for href with single quote and second for double quote) and replace it with whatever domain you need (and don't forget to escape it properly).
Some notes
I don't know which regexp function you want to use, but you should be able to use it with whatever regexp function you need. Another thing is that your example click here won't be matched, because you have spaces between attribute name and = sign (i don't know if this is valid HTML or not). It will work with this click here . If you need to match addresses which might include spaces between = signs just comment me and I'll try to edit the regex.

Slash included words from string

I have a string as follows and I want to have only highlighted text in RegEx:
"Datapath from SF7PCRINFVCR1/MPLS to SF2PCRINFVCR1/MPLS for fwdClass fc_nc is down".
I have tried the RegEx (?<=Datapath from ).*?(?= for) but I am expecting the result as second row under Group Details [attached screenshot] with
Match#2 GroupIndex#1 and GroupContent as SF7PCRINFVCR1/MPLS to SF2PCRINFVCR1/MPLS from the below site as my integration tool is looking for second entry form the Group Details section.
https://www.freeformatter.com/java-regex-tester.html#before-output
Expecting output like

How do I use regex to return text following specific prefixes?

I'm using an application called Firemon which uses regex to pull text out of various fields. I'm unsure what specific version of regex it uses, I can't find a reference to this in the documentation.
My raw text will always be in the following format:
CM: 12345
APP: App Name
BZU: Dept Name
REQ: First Last
JST: Text text text text.
CM will always be an integer, JST will be sentence that may span multiple lines, and the other fields will be strings that consist of 1-2 words - and there's always a return after each section.
The application, Firemon, has me create a regex entry for each field. Something simple that looks for each prefix and then a return should work, because I return after each value. I've tried several variations, such as "BZU:\s*(.*)", but can't seem to find something that works.
EDIT: To be clear I'm trying to get the value after each prefix. Firemon has a section for each field. "APP" for example is a field. I need a regex example to find "APP:" and return the text after it. So something as simple as regex that identifies "APP:", and grabs everything after the : and before the return would probably work.
You can use (?=\w+ )(.*)
Positive lookahead will remove prefix and space character from match groups and you will in each match get text after space.
I am a little late to the game, but maybe this is still an issue.
In the more recent versions of FireMon, sample regexes are provided. For instance:
jst:\s*([^;]?)\s;
will match on:
jst:anything in here;
and result in
anything in here

extracting a part of an href in JMeter

i'm stuck with the following.
i have a page on ibm filenet containing a list with objects (these are documents or files) which have a specific classID and ID in their href. i need JMeter to get all HREFS containing a specific type of ID:
<a href="http://ipaddress/Workplace/Browse.jsp?eventTarget=WcmController&eventName=GetInfo&id={350B278C-DE7D-44DE-9B54-099672152476}&vsId=&classId={F14AC85A-4474-479A-9B4E-BCBA180B7975}&objectStoreName=Nice&majorVersion=&minorVersion=&versionStatus=&mimeType=&mode=&objectType=customobject&isPopup=true" target="_blank">
the 'classId' = {F14AC85A-4474-479A-9B4E-BCBA180B7975} is the right class id type i need to click on the page (there are several files with this classID but that is no problem). on the other hand the 'id' is thus different for each file.
how can i extract all 'id's containing this specific classId and make JMeter pass it to the next sampler, so it clicks on just one of them? what will my RegEx look like?
As already mentionned in the comment, I do not know jmeter and how to implement it in the code. A regular expression to match both id and classId within a link would be:
~(classId=|id=)([^&]*)~g
This is, search for a string classId= or id= first. If one of the strings is found, match any character afterwards, except an ampersand (&), as many times as possible (*) and capture it in a group (brackets). Possibly you need to fiddle with the parameters (e.g. /g for global) after the regex.
See this regex101 fiddle for more information.

Replacing Anchor in JSTL

In my JSP I have receive some data which is coming from database my data is for example something like this :
Google is the greatest search engine ever http://www.google.com
what I wanna do is so simple: I want to make this link wrap in anchor tag using JSTL something like:
Google is the greatest search engine ever http://www.google.com
that's all !
take note that the urls are not constant, I mean I'm not sure what that be exactly & I just mentioned google here for the example.
Follow this SO question to create a replaceAll function for JSTL and then use the following pattern to replace the url to html link:
String pattern = "(http:[A-z0-9./~%]+)";
String str = "Google is the http://www.test.com greatest search engine ever http://www.google.com";
String replaced = str.replaceAll(pattern, "<a href='$1'>$1</a>");