String format - practice language - trace32 - trace32

In the Trace32 language--Practice-- is there a command for formatting strings? I know of the format.hex() and format.decimal() commands but I have had no luck finding anything like a format.string()

Try with:
FORMAT.STRING("string", 20, ' ' )
-> "string" to be output, 20 is the length, ' ' is fill character

There are string functions available for Trace32. These can be found in the ide_func.pdf help document. Please find the string functions in the below link mentioned.
http://www2.lauterbach.com/pdf/ide_func.pdf
Hope this will be helpful.
Thanks,
Shivakumar V W

Related

Vb net Regex retrieve data up to specific keyword or end of string

I have several string like
kw_CS_TABLE__FC29-001::details=MIN_CAT::title=xxxx
kw_CS_TABLE__FC29-002::details=CAT to NSE
kw_CS_TABLE__FC29-003::details=HAZMIN::
I want to retrieve only the details string (MIN_CAT, CAT to NSE, HAZMIN).
I use the regex (?<=::details=)(.*)(?=::), it looks fine for the first and 3rd case. But it fails for the second case.
I am struggle with the recognition of the end of the string. I use the |$ command, but in this case, I retrieve all the sentence up to the end of the file.
(?<=::details=)(.*)(?=::|$)
kw_CS_TABLE__FC29-001::details=MIN_CAT::title=xxxx
returns > MIN_CAT::title=xxxx
I have a lots of difficulties to understand the regex concepts, especially because I use it only for some specific case. I read several tutorials and posts, but nothing solve my problem.
Thanks
Without regex
Private Function GetDetailsFrom(line As String) As String
Return line.Split({"::"}, StringSplitOptions.None).
Where(Function(item) item.StartsWith("details")).
Select(Function(detail) detail.Split({"="c}).LastOrDefault()).
FirstOrDefault()
End Function
Usage
Dim lines As String() =
{
"kw_CS_TABLE__FC29-001::details=MIN_CAT::title=xxxx",
"kw_CS_TABLE__FC29-002::details=CAT to NSE",
"kw_CS_TABLE__FC29-003::details=HAZMIN::"
}
Dim details = lines.Select(AddressOf GetDetailsFrom)
Console.WriteLine(string.Join(Environment.NewLine, details))
' MIN_CAT
' CAT to NSE
' HAZMIN

Remove all symbols while preserving string consistency [duplicate]

This question already has an answer here:
Maintaining the consistency of strings before and after converting to ASCII
(1 answer)
Closed 7 years ago.
My goal is to remove all symbols from a string and still preserve the unicode characters (alphabetical character from any language). Suppose I have the following string:
carbon copolymers—III❏£\n12- Géotechnique\n
I want to remove the —, ❏ and £ characters between copolymers and \n. I was looking at here and thought maybe I should go with regex and remove all symbols given the correct unicode characters range. The range of characters that I have in my text file varies from Latin to Russian and ... . However the regex code I've written below doesn't help.
>>> s = u'carbon copolymers—III❏£\n12- Géotechnique\n'
>>> re.sub(ur'[^\u0020-\u00FF\n]+',' ', s)
There seems to be two problems with this method:
1) Different unicode ranges still include some symbols.
2) Sometimes, for some unknown reason the returned result seems to be totally different than what it is supposed to be.
Here's the result of the code above:
carbon copolymers\xe2\x80\x94III\n12- G\xc3\xa9otechnique\n
>>> print u'carbon copolymers\xe2\x80\x94III\n12- G\xc3\xa9otechnique\n'
carbon copolymersâIII
12- Géotechnique
Do you know any better way of doing this? Is there a full list of all symbols? Do you have any other ideas rather than regex?
Thank you
I think found a good solution (>99% robust I believe) to the problem:
Well here's our new, horrific string:
s = u'carbon҂ ҉ copolymers—⿴٬ٯ٪III❏£\n12-ः׶ Ǣ ܊ܔ ۩۝۞ء܅۵Géotechnique▣ऀ\n'
And here's the resulting string:
u'carbon copolymers \u066f III \n \u01e2 \u0714 \u0621 G\xe9otechnique \n'
All the remained characters/words are in fact alphabetical characters, in different languages. Done with almost no effort!
Here's the solution:
s = ''.join([c if c.isalpha() or c.isspace() else ' ' for c in s])
s = re.sub(ur'[\u0020-\u0040]+|[\u005B-\u0060]+|[\u007B-\u00BF]+', ' ', s)
s = re.sub(r'[ ]+', ' ', s)
carbon copolymers ٯ III
Ǣ ܔ ء Géotechnique

Matlab regex: replace comma and one letter

I have a string like this in matlab.
str='42 21 S'
How could I convert it into the following form?
str='42.21'
What I tried with regexprep() is the following:
regexprep(str,'S','');
regexprep(str,' ', '.')
which leaves me with this
str='42.21.'
This ought to do the trick, Matlab is not great with strings though so there's likely to be all sorts of ways to do it, not just using regexp/regexprep:
regexprep(regexp('42 21 A','\d+\s\d+','match'),'\s','.')
The regexp removes the space and the S at the end, and then the regexprep replaces the space with a period.
For simple replacements you don't have to use regexprep. You can use the much simpler strrep:
str = strrep(str, ' S', '');
str = strrep(str, ' ', '.');
If you require more general replacement rules, you should use regexprep, like David's answer for example.

Replace parts in a string using REGEXP_REPLACE

Hi I have a string in oracle like this:
temp_a, temp_b, temp_c
What I want to get is :
e.temp_a, e.temp_b, e.temp_c
So I want to put an "e." before every part in this string
I searched in internet and I found examples to split the string or to replace simpler strings but nothing to guide me through my problem
select regexp_replace('temp_a, temp_b, temp_c',
'([a-zA-Z0-9_]+)(,?)',
'e.\1\2') from dual;
This should work.
I just noticed you're specifically asking for regex, but for what it's worth I would probably do it like this:
rtrim( replace( 'e.'||your_string, ', ', ', e.'), 'e.')

Perl decimal to ASCII conversion

I am pulling SNMP information from an F5 LTM, and storing this information in a psql database. I need help converting the returned data in decimal format into ASCII characters.
Here is an example of the information returned from the SNMP request:
iso.3.6.1.4.1.3375.2.2.10.2.3.1.9.10.102.111.114.119.97.114.100.95.118.115 = Counter64: 0
In my script, I need to identify the different sections of this information:
my ($prefix, $num, $char-len, $vs) = ($oid =~ /($vsTable)\.(\d+)\.(\d+)\.(.+)/);
This gives me the following:
(prefix= .1.3.6.1.4.1.3375.2.2.10.2.3.1)
(num= 9 )
(char-len= 10 )
(vs= 102.111.114.119.97.114.100.95.118.115)
The variable $vs is the Object name in decimal format. I would like to convert this to ASCII characters (which should be "forward_vs").
Does anyone have a suggestion on how to do this?
Given that this is related to interpreting SNMP data, it seems logical to me to use one or more of the SNMP modules available from CPAN. You have to know quite a lot about SNMP to determine when the string you quote stops being the identifier (prefix) and starts to be the value. You have a better chance of getting a general solution with SNMP code than with hand-hacked code.
Jonathan Leffler has the right answer, but here are a couple of things to expand your Perl horizons:
use v5.10;
$_ = "102.111.114.119.97.114.100.95.118.115";
say "Version 1: " => eval;
say "Version 2: " => pack "W".(1+y/.//) => /\d+/g;
Executed, that prints:
Version 1: forward_vs
Version 2: forward_vs
Once both are clear to you, you may hit space to continue or q to quit. :)
EDIT: The last one can also be written
pack "WW".y/.//,/\d+/g
But please don't. :)
my $new_vs = join("", map { chr($_) } split(/\./,$vs));
Simple solution:
$ascii .= chr for split /\./, $vs;
pack 'C*', split /\./
For example,
>perl -E"say pack 'C*', split /\./, $ARGV[0]" 102.111.114.119.97.114.100.95.118.115
forward_vs