As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
I have a string in my data that I need to cut the head off if its start matches the regular expression: /^[Qq][Rr][1-5][:;]\s*/ Meaning, if the string starts with 'QR' (regardless of case), followed by a semi-colon or a colon and any following white-space, I need to cut that part off it.
I've seen some approaches that replaced constant strings, but that would hardly suffice in my case.
Is there some way to do this? Pretty much any language I know of does have this ability, I suppose WebFOCUS does too?
Examples:
original | result
-------------------+--------
Qr1: Pilot | Pilot
QR4;Production | Production
qr2: Testing | Testing
This message has been edited. Last edited by: Kerry,
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
I did manage a hand-crafted "solution", see below. It's not very flexible, but it fits my immediate needs.
DEFINE FILE CAR
CARUP/A128V = UPCASE(128, CAR, CARUP);
HDLEN/I2 = IF (EDIT(CARUP, '99') EQ 'QR') AND (EDIT(CARUP, '$$9') EQ '1' OR '2' OR '3' OR '4' OR '5') AND (EDIT(CARUP, '$$$9') EQ ':' OR ';')
THEN 5 ELSE 1;
CARTAIL/A128V = SUBSTR(128, CAR, HDLEN, 128, 128 - HDLEN, CARTAIL);
CAR2/A128V = TRIM('B', CARTAIL, 128 - HDLEN, ' ', 1, CAR2);
END
TABLE FILE CAR
PRINT CAR
END
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
Come on guys, it's 2011! We're not living in the 80's anymore... Isn't it about time for WebFOCUS to sprout some modern features?
Other languages have regular expression support. They use variable length strings by default, aren't riddled with arbitrarily short length limitations, usually have an extensive and convenient library of built-in functions for - say - date formatting, etc, etc.
Way too much of my time is spent on getting WebFOCUS to behave. I don'tget to spend my time developing, I'm too busy bashing a bloody dinosaur into shape with my bone club.
If I would be asked to advise a company on a reporting solution, WebFOCUS would be among the bottom of my list. Unfortunately it's the only reporting solution I'm familiar with - doesn't matter, being better than the competition (and I doubt WF is better) doesn't make a product good, just less bad.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
The result is 'ZDEFGHIJKLMNO'. This is a "constant", your example "is not".
SQL
SELECT CHAR(REPLACE( 'DINING', 'N', 'VID' ), 10), FROM SYSIBM.SYSDUMMY1
The result is 'DIVIDIVIDG'. Again, a constant.
OR, SQL CASE logic, which is just as much code as WebFOCUS...
Of course, all of the above DID NOT give you your correct string because SUBSTR has not even been used yet, which, if I was coding in SQL, would use CASE logic...
So, let us ALL know of the function(s) you are referring to...
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
Originally posted by Tom Flynn: and, you forgot JavaScript...
As I said, "to name a few". There are plenty other languages that I didn't mention that support regexes and I was fully aware that Javascript is one of them when I wrote that - I just chose to not mention it, as several other languages.
quote:
And, where's the substring in your examples, and, removing spaces?
You seem to have gotten confused by my workaround without regexes, to get the desired result in WebFOCUS. The substring and trim are only needed because WebFOCUS doesn't support regexes, which is the reason we're having this conversation.
But if you need an example, in Postgres I'd have done:
SELECT regexp_replace(CAR, '/^[Qq][Rr][1-5][:;]\s*/', '') FROM CAR
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
I don't need an example, I've done this via SQL many times, through WebFOCUS. And, I especially don't need a database engine example, either.
We are in 2011, remember, and your negativity/lambasting of WebFOCUS for not having functions that would accomplish your need, yet, you don't site a single example from another reporting tool, but, you use SQL.
Yes, your workaround works, and, so does mine. The flexibility of WebFOCUS allows for many ways to accomplish certain tasks, even those that address a lousy front end/ETL tool.
People are using computers to make their work easier, not to make it harder.
Especially in the reporting business it must be quite common that data from a data-source doesn't exactly match what you need, or that data from different sources use different representations for the same thing. It is very likely that especially your customers run into situations like these a lot, and WebFOCUS is not helping, because it does not provide regex support. IMHO that would be a great feature and I'm quite surprised it's not already implemented, seeing how common these are in the world of computing.
Suggesting to solve the problem using native SQL, well... what was the reason we use WebFOCUS in the first place again? There are always some things require native SQL, but kneading data into a usable shape shouldn't be among them.
It's a shame that you only look at other reporting tools to compare what features WebFOCUS would benefit from. Yes, you should keep an eye on the competition to stay competitive, but don't you have any intention to go beyond that?
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
I pray I never have to write anything like this gibberish to do something in WebFOCUS. I want my fourth generation language to stay that way (or maybe progress to fifth, but not go back to third or second generation syntax). That doesn't mean WF couldn't do with some fancy new functions and improved capabilities. I have skirmishes with this software almost every day (in many ways the fun part of my day). But remember that it is essentially a mainframe language that had to transform itself for the Web. So it has a lot of old baggage that it still has to schlepp around. I for one have been truly amazed at some of the ways IBI has managed to get this old dog do some of the tricks it does today. The GUIs still suck (partly because a lot of that clicking and dragging must translate into good old FOCUS code), but if you're fluent in the FOCUS language, you can be the master of your data universe. On the other hand, I was not happy about ReportBroker's devolution into ReportCaster (Focus code --> Java), nor the fact that -CRTFORM and Dialogue Manager can't be used to build Web launch pages, which instead require learning foreign tongues like HTML, JavaScript, XML, and what next? Yes, do make WF better, more powerful, easier to use, etc., etc., but please don't make it any more difficult to understand than it already is.
WebFOCUS 7.7.05
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007
I suppose regular expressions are from the UNIX world. Not many Windows applications seem to have support for it - the few that do usually are related to programming.
Regular expressions are a way to describe a pattern that a string (or substring) should match for an operation to apply to it. They're usually placed between '/'s, after which you can specify some options like whether the pattern as a whole repeats, whether it should be applied case-sensitive or not, whether to handle new-lines, etc.
The pattern quoted: /^[Qq][Rr][1-5][:;]\s*/ means: ^ - if it starts with... [Qq] - a 'Q' or 'q', followed by [Rr] - a 'R' or 'r', followed by [1-5] - a character (number) from '1' to '5', followed by [:;] - a ':' or ';', followed by \s* - any number of white-space characters (or none)
Used in regexp_replace(pattern, string, substitution) this replaces the part of the string that matches the pattern by the string in substitution.
In my case I wanted to remove the start of strings that are like "Qr3: ", which is what the mentioned regular expression used with the regexp_replace-function would accomplish.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :