I have custom function keyword like ToString, ToUpper, ToLower etc. I want to highlight these function keyword after (.) dot
i have changed the "support.function" in the highlight rules.
But it is highlighting without (.), if i put (.) before the function name, then it is not highlighting.
i have modified like this, except this everything is same.
var keywordMapper = this.createKeywordMapper({
"variable.language": "M|D|H|S|Now|ATime|ETime",
"keyword": "Double|DateTime|String|if|then|else|endif|CTYPE",
"storage.type":"",
"constant.language":"",
"support.function": "Abs|Ceil|Exp|Floor|Log|ln|Pow|Round|Sqrt|cos|sin|tan|cosh|sinh|tanh|acos|asin|atan|Max" +
"|Min|Sum|Std|Var|Average|Norm|Median|Count|TWA|Interpolate|Bitset|Bitget|Range|Group" +
"|ROC|Ema|IsNan|IsNull|IsBad|ReplaceBadValue|OverrideValue|LogMsg|ThrowError|Quality|Filter" +
"|DTValue|Time|DTAdd|Age|SubString|Replace|Trim|Length|ToLower|.ToUpper|ToNumber|ToString|Contains",
"constant.language.boolean": "true|false"
}, "identifier");
var kwBeforeRe = "if|then";
This depends on the regexp of the state to which keywordMapper is applied, it doesn't match dot, you most likely need to add a new state for the properties after dot similar to javascript mode and add another keyowrdMapper for that state.
Related
Is there an api implementation for "decorating" a string pattern in Ace Editor (or how would you do it)?
Say you have two variables with ids and names. E.g.:
{
"$id1": "variable_1_name",
"$id2": "varialbe_2_name",
}
You pass the editor the value $id1 + $id2 but want it rendered as variable_1_name + variable_2_name ?
I'm looking for something similar to how draftjs handles this use case: https://draftjs.org/docs/advanced-topics-decorators
I Guys
In forms I use,
onKeyUp="this.value = this.value.toUpperCase()"
To force upper-case. However for such as name fields. How do you force the upper letter to be upper-case only while the user is typing. I know INITCAP will do that but need to do as user is typing, if that makes sense.
Any help will be much appreciated.
This is a javascript question then, not and Oracle or APEX question. It shouldn't make any difference what the environment is as long as you have access to the DOM events with javascript functions. e.g. http://www.w3schools.com/jsref/event_onkeyup.asp
If you do a search there are lots of examples to Initcap a string in javascript, just pass in the string and reset the item in the dom e.g.
function capitalizeEachWord(str) {
return str.replace(/\w\S*/g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
I tried to solve this problem.
For that I created JavaScript function which check first letter capital ,if not then it display alert and revert text.
please check following code for text item:
function checkUpper()
{
var x = $x("P6_TEXT");
if (x.value.trim().substring(0,1) != x.value.trim().substring(0,1).toUpperCase()) {
alert ('First letter Must be in upper case');
x.value = x.value.trim().substring(0,x.value.trim().length-1).toString();
}
}
And set item P6_TEXT attribute as
onKeyUp="checkUpper();"
In the field custom attributes put this JS code:
onKeyUp="this.value = this.value.substring(0,1).toUpperCase()+this.value.substring(1).toLowerCase();"
You could use content modifiers from Universal Theme https://apex.oracle.com/pls/apex/apex_pm/r/ut/content-modifiers
I needed text in a page item to be uppercase and under Advanced I set the css classe to
u-textUpper
u-textInitCap - Sets The First Letter In Each Word To Use Uppercase
I'm facing an issue with CKEditor 4, I need to have an output without any html entity so I added config.entities = false; in my config, but some appear when
an inline tag is inserted: the space before is replaced with
text is pasted: every space is replaced with even with config.forcePasteAsPlainText = true;
You can check that on any demo by typing
test test
eg.
Do you know how I can prevent this behaviour?
Thanks!
Based on Reinmars accepted answer and the Entities plugin I created a small plugin with an HTML filter which removes redundant entities. The regular expression could be improved to suit other situations, so please edit this answer.
/*
* Remove entities which were inserted ie. when removing a space and
* immediately inputting a space.
*
* NB: We could also set config.basicEntities to false, but this is stongly
* adviced against since this also does not turn ie. < into <.
* #link http://stackoverflow.com/a/16468264/328272
*
* Based on StackOverflow answer.
* #link http://stackoverflow.com/a/14549010/328272
*/
CKEDITOR.plugins.add('removeRedundantNBSP', {
afterInit: function(editor) {
var config = editor.config,
dataProcessor = editor.dataProcessor,
htmlFilter = dataProcessor && dataProcessor.htmlFilter;
if (htmlFilter) {
htmlFilter.addRules({
text: function(text) {
return text.replace(/(\w) /g, '$1 ');
}
}, {
applyToAll: true,
excludeNestedEditable: true
});
}
}
});
These entities:
// Base HTML entities.
var htmlbase = 'nbsp,gt,lt,amp';
Are an exception. To get rid of them you can set basicEntities: false. But as docs mention this is an insecure setting. So if you only want to remove , then I should just use regexp on output data (e.g. by adding listener for #getData) or, if you want to be more precise, add your own rule to htmlFilter just like entities plugin does here.
Remove all but not <tag> </tag> with Javascript Regexp
This is especially helpful with CKEditor as it creates lines like <p> </p>, which you might want to keep.
Background: I first tried to make a one-liner Javascript using lookaround assertions. It seems you can't chain them, at least not yet. My first approach was unsuccesful:
return text.replace(/(?<!\>) (?!<\/)/gi, " ")
// Removes but not <p> </p>
// It works, but does not remove `<p> blah </p>`.
Here is my updated working one-liner code:
return text.replace(/(?<!\>\s.)( (?!<\/)|(?<!\>) <\/p>)/gi, " ")
This works as intended. You can test it here.
However, this is a shady practise as lookarounds are not fully supported by some browsers.
Read more about Assertions.
What I ended up using in my production code:
I ended up doing a bit hacky approach with multiple replace(). This should work on all browsers.
.trim() // Remove whitespaces
.replace(/\u00a0/g, " ") // Remove unicode non-breaking space
.replace(/((<\w+>)\s*( )\s*(<\/\w+>))/gi, "$2<!--BOOM-->$4") // Replace empty nbsp tags with BOOM
.replace(/ /gi, " ") // remove all
.replace(/((<\w+>)\s*(<!--BOOM-->)\s*(<\/\w+>))/gi, "$2 $4") // Replace BOOM back to empty tags
If you have a better suggestion, I would be happy to hear 😊.
I needed to change the regular expression Imeus sent, in my case, I use TYPO3 and needed to edit the backend editor. This one didn't work. Maybe it can help another one that has the same problem :)
return text.replace(/ /g, ' ');
In the case of following string to be parsed.
ford mustang,10,blue~~?bugatti veyron,13,black
I want to replace the ~~? with a carriage return
Replacing with \n just adds the string "\n"
How can this be done?
Make sure Use: Regular expressions is selected in the Find and Replace dialog:
Note that for Visual Studio 2010, this doesn't work in the Visual Studio Productivity Power Tools' Quick Find extension (as of the July 2011 update); instead, you'll need to use the full Find and Replace dialog (use Ctrl+Shift+H, or Edit --> Find and Replace --> Replace in Files), and change the scope to Current Document.
You can also try \x0d\x0a in the "Replace with" box with "Use regular Expression" box checked to get carriage return + line feed using Visual Studio Find/Replace.
Using \n (line feed) is the same as \x0a
If you set Use regular expressions flag then the \n character would be translated. But keep in mind that you would have to modify your search term to be regexp friendly. In your case it should be escaped like this \~\~\?.
If you want to avoid the hassle of escaping the special characters in your search and replacement string when using regular expressions, do the following steps:
Search for your original string, and replace it with "UniqueString42", with regular expressions off.
Search for "UniqueString42" and replace it with "UniqueString42\nUniqueString1337", with regular expressions on
Search for "UniqueString42" and replace it with the first line of your replacement (often your original string), with regular expressions off.
Search for "UniqueString42" and replace it with the second line of your replacement, with regular expressions off.
Note that even if you want to manually pich matches for the first search and replace, you can safely use "replace all" for the three last steps.
Example
For example, if you want to replace this:
public IFoo SomeField { get { return this.SomeField; } }
with that:
public IFoo Foo { get { return this.MyFoo; } }
public IBar Bar { get { return this.MyBar; } }
You would do the following substitutions:
public IFoo SomeField { get { return this.SomeField; } } → XOXOXOXO (regex off).
XOXOXOXO → XOXOXOXO\nHUHUHUHU (regex on).
XOXOXOXO → public IFoo Foo { get { return this.MyFoo; } } (regex off).
HUHUHUHU → public IFoo Bar { get { return this.MyBar; } } (regex off).
You can use Multiline Search and Replace in Visual Studio macro which provides nice GUI for the task.
Just a minor word of warning... a lot of environments use, or need, "\r\n" and not just "\n". I ran into an issue with Visual Studio not matching my regex string at the end of the line because I left off the "\r" of "\r\n", so my string couldn't match with a missing invisible character.
So, if you are doing a find, or a replace, consider the "\r".
For a little more detail on "\r" and "\n", see: https://stackoverflow.com/a/3451192/4427457
I am having a little bit of difficulty passing a variable into a selector in prototype. I would like to be able to pass a variable into the select string, so that one function can work for many of the same kind.
At the moment, this is what I would basically like to do:
function myFunct(var)
{
$(var + 'add_form').hide() //so inde the brackets would be ('#product1 #add_form') for example.
}
Be able to pass 'var' into the function that would pass it to the selector, so that I can hide a pattern that is the same for many on the page.
Any ideas for a path to follow would be greatly appreciated.
You're on the right track! Couple things:
var is a JavaScript keyword (source), don't use it to name a variable
if you're querying an element by id (such as #add_form) you don't need to add any container element as you're doing
If you're querying an element by class, you need to use the $$ function, not the $ function
You need to iterate over the wrapped set to call your method
whitespace is significant in css selectors, so make sure to include those in your selector construction to tell Prototype to search within your parent container:
function myFunct(parent) {
$$(parent + ' .add_form').invoke('hide')
}
myFunct('#someparent'); // hides .add_form inside #someparent
That should work... just rename var to something else.
function myFunct(yourVar)
{
$$('#' + yourVar + ' .add_form').each(function(s){ s.hide(); }); // yourVar being the id of the container element
}
I've put a '.' in front of add_form because you can't use multiple elements with same ID, make it a class.