Showing posts with label RegEx. Show all posts
Showing posts with label RegEx. Show all posts

Sunday, May 15, 2016

PeopleTools 8.54+ - Branding - Part 4E - Customizing DEFAULT_THEME_TANGERINE_ALT Theme (Continued)

In my previous post (Branding Part 3), there were a series of questions/comments on how to add an external link to the Classic Branding header in PeopleTools 8.54.

In this link, I demonstrated how we could add an external link and open it in a new window using the Header definition.

But what if we wanted to add the 'New Window' link that is generally available at the component level to the Classic Branding header in PeopleTools 8.54? Assuming that is what the following comment suggests.

The steps would be very similar to adding an external link but we would be using javascript instead of using a static URL.

Adding 'New Window' link on the Classic Branding Header in PeopleTools 8.54:

- Add an element to the Header definition under pthdr2syslinks.


- Add JavaScript in URL attribute under the Static URL section.




Note: The 'Target' attribute value does not matter and we can leave it as the default (_top).

Custom JavaScript for reference:



- Element Properties - Set Order.


Results:




Sunday, November 8, 2015

Oracle SQL: REGEX_REPLACE Function

Recently, I participated in a forum discussion (Higher Education User Group) where someone asked if there is a way (and if so how) to strip out HTML elements from a long character field. This is mainly for scenarios where a long character field is used to store rich text enabled data (which contains HTML elements). And while querying the data from this field either using PS Query or SQL the requirement is to only retrieve the "plain text".

I found that we could use a delivered Oracle SQL function called REGEX_REPLACE to pattern match and replace contents of a string.

Here are some examples of how to use this function:

If we want to mainly get rid of HTML elements then we can use the following pattern:

select REGEXP_REPLACE(DESCRLONG, '<[^>]+>|\&(nbsp;)|\&(nbsp)|(amp;)', '',1,0, 'i'), DESCRLONG from PSMSGCATDEFN where descrlong like '%<%>%';

If we additionally want to get rid of contents inside script/style elements then we can use the following pattern:

select REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE(DESCRLONG, '<script[^>]*>.*</script>', '',1,0,'in'), '<style[^>]*>.*</style>', '',1,0,'in'),'<[^>]+>|\&(nbsp;)|\&(nbsp)|(amp;)', '',1,0,'i'), DESCRLONG from spsoft.PSMSGCATDEFN where descrlong like '%<%>%';

Note:
- You will need to improvise the regex pattern for those cases which are not trapped in the above sample SQLs.
- This function REGEX_REPLACE only works on Oracle databases.
- I have to admit that I am not a RegEx expert and received help from some very talented colleagues who helped me with the second (more complex) SQL.

Saturday, September 26, 2015

Regular Expression Pattern Matching for PeopleSoft Trace/Log Files

Have you ever wondered how to remove some of the timing and other environment specific information from a trace/log file so that we only see the SQL and PeopleCode?

The timing and other information that I am referring to are:

SQL:


PeopleCode:



Why?

While these timing and other information in the trace file are great for performance tuning activities, they seem to cause several issues (at least for me) when doing a comparative analysis. By comparative analysis, I mean comparing the trace files across different scenarios to identify a problem. For example, an issue might only occur for user A but does not occur for user B. Then we would be inclined towards comparing the trace files generated for user A and user B in an effort to identify the problem. Similarly, an issue might only occur in a particular environment (say TEST) whereas it works fine in another environment (say DEVELOPMENT). Again we would be inclined towards comparing the trace files generated in TEST and DEVELOPMENT to identify the problem.

Now that I detailed the scenario/activity, I would like to describe the problem. When we try to compare two different trace files using any file compare tools (such as WinMerge), the results would identify a difference on almost every single line! Most of them would be false positives due to the timing and other information which is not really useful in such cases.

E.g.:



Regular Expressions (RegEx) Pattern Matching for PeopleSoft Trace/Log Files:

So, if we get rid of (or mask the unncessary information) then we can determine the "actual" differences more efficiently.

That is where Regular Expression (RegEx) pattern matching helps in identifying and removing/masking unncessary information.

Note: I generally use notepad++ for text editing. I am sure most text editors would have a similar RegEx find/replace functionality.

RegEx Pattern for SQL:

Find: ^[a-z]{8}\.\d+ +\(\d+\) +\t +\d+-\d+ +\d{2}\.\d{2}\.\d{2} +\d+\.\d{6} Cur#\d+\.\d+\.[a-zA-Z0-9_]+ RC=\d+ Dur=\d+.\d{6}
Replace: SQL---------------


RegEx Pattern for PeopleCode: 

Find: ^[a-z]{8}\.\d+ +\(\d+\) +\t +\d+-\d+ +\d{2}\.\d{2}\.\d{2} +\d+.\d{6}
Replace: PeopleCode--------


Benefits of Regex Pattern Matching Find/Replace During Comparative Analysis:

Now, if we remove all the unnecessary information and then compare, we would be able to determine the differences quickly and easily. Here is an example of how I used the RegEx Find/Replace (detailed above) and then compared two different trace files using WinMerge.


Similarly, we can use Regex Pattern Matching to intelligently find and replace specific portions of the trace/log files to improve readability!