Find some text characters

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Find some text characters

J. Landman Gay via use-livecode
Is there a easy way to do this?:

Given this htmlText that may contain Chinese characters and/or some horizontal tabs—

			大胆的强

I want to know if this data contains Chinese characters, that is an entity with 5 numbers between the “#” and the “;”

Only data containing 5 numbers between the “#” and the “;” would return true. Having ONLY "	” but not the other would return false.

Thanks for suggestions!

Peter Bogdanoff
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
If the number of chars in tItem = 8 then...

You always have three extra chars, so that should be right.

If you need an itemdelimiter, use "&" and check if the number of chars in each item = 7

Sent from my iPhone

> On Jul 17, 2017, at 5:40 PM, Peter Bogdanoff via use-livecode <[hidden email]> wrote:
>
> Is there a easy way to do this?:
>
> Given this htmlText that may contain Chinese characters and/or some horizontal tabs—
>
> &#9;&#9;&#9;&#22823;&#32966;&#30340;&#24378;
>
> I want to know if this data contains Chinese characters, that is an entity with 5 numbers between the “#” and the “;”
>
> Only data containing 5 numbers between the “#” and the “;” would return true. Having ONLY "&#9;” but not the other would return false.
>
> Thanks for suggestions!
>
> Peter Bogdanoff
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode

Given this htmlText that may contain Chinese characters and/or some horizontal
tabs—

&#9;&#9;&#9;&#22823;&#32966;&#30340;&#24378;

I want to know if this data contains Chinese characters, that is an entity with
5 numbers between the “#” and the “;”




according to google-translate this means "bold and strong"

maybe this is a way?


   set the htmlText of field 1 to "<p>&#9;&#9;&#9;&#22823;&#32966;&#30340;&#24378;</p>"

   put the number of truewords of field 1 into field 2

   set the itemDelimiter to tab

   put cr & the number of items of field 1 after field 2

still doesn't tell you if is numbers or not though

Kind regards
Bernd

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
Could replace tab with empty first, if the tabs do not matter in the final product

I imagine LC provides many ways to do this :)

Sent from my iPhone

> On Jul 17, 2017, at 6:20 PM, Niggemann, Bernd via use-livecode <[hidden email]> wrote:
>
>
> Given this htmlText that may contain Chinese characters and/or some horizontal
> tabs—
>
> &#9;&#9;&#9;&#22823;&#32966;&#30340;&#24378;
>
> I want to know if this data contains Chinese characters, that is an entity with
> 5 numbers between the “#” and the “;”
>
>
>
>
> according to google-translate this means "bold and strong"
>
> maybe this is a way?
>
>
>   set the htmlText of field 1 to "<p>&#9;&#9;&#9;&#22823;&#32966;&#30340;&#24378;</p>"
>
>   put the number of truewords of field 1 into field 2
>
>   set the itemDelimiter to tab
>
>   put cr & the number of items of field 1 after field 2
>
> still doesn't tell you if is numbers or not though
>
> Kind regards
> Bernd
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

dunbarx
This cries out for regex.

Thierry?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
Another way, just for fun

Put empty into tnums
Repeat for each char tchar in tstring

If isnumber(tchar) = true then
Put tchar after tnums
Else if tnums <> empty then
If the number of chars in tnums = 5 then
Put tnums & linefeed after tnumlist
End if
Put empty into tnums
End if
End repeat

This should give a list of all 5 number sets

Sent from my iPhone

> On Jul 17, 2017, at 6:45 PM, dunbarx via use-livecode <[hidden email]> wrote:
>
> This cries out for regex.
>
> Thierry?
>
>
>
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Find-some-text-characters-tp4717138p4717143.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
Another way... just playing around

Replace tab with empty in tstring
Replace ";" with empty in tstring
Replace "#" with empty in tstring
Replace "&" with linefeed in tstring
Repeat for each line tLine in tstring
If the number of chars in tLine = 5 then
Put tLine and linefeed after tList
End if
End repeat
Delete char -1 of tList

Sent from my iPhone

> On Jul 17, 2017, at 7:50 PM, [hidden email] wrote:
>
> Another way, just for fun
>
> Put empty into tnums
> Repeat for each char tchar in tstring
>
> If isnumber(tchar) = true then
> Put tchar after tnums
> Else if tnums <> empty then
> If the number of chars in tnums = 5 then
> Put tnums & linefeed after tnumlist
> End if
> Put empty into tnums
> End if
> End repeat
>
> This should give a list of all 5 number sets
>
> Sent from my iPhone
>
>> On Jul 17, 2017, at 6:45 PM, dunbarx via use-livecode <[hidden email]> wrote:
>>
>> This cries out for regex.
>>
>> Thierry?
>>
>>
>>
>> --
>> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Find-some-text-characters-tp4717138p4717143.html
>> Sent from the Revolution - User mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
2017-07-17 23:40 GMT+02:00 Peter Bogdanoff via use-livecode <
[hidden email]>:

> Is there a easy way to do this?:
>
> Given this htmlText that may contain Chinese characters and/or some
> horizontal tabs—
>
> &#9;&#9;&#9;&#22823;&#32966;&#30340;&#24378;
>
> I want to know if this data contains Chinese characters, that is an entity
> with 5 numbers between the “#” and the “;”
>
> Only data containing 5 numbers between the “#” and the “;” would return
> true. Having ONLY "&#9;” but not the other would return false.
>
> Thanks for suggestions!
>
> Peter Bogdanoff
>
>
​Hi Peter,


​Mmm, not sure you'll get *only* Chinese characters,
but at least any entity with only 5 numbers.

This function returns true if find any, false otherwise:

function testForChinese T
​xt​
​ -- any htmltext​
   return matchText(
​Txt
, "&#\d{5};")
end testForChinese


​Regards,

Thierry​


--
------------------------------------------------
Thierry Douez - sunny-tdz.com
sunnYrex - sunnYtext2speech - sunnYperl - sunnYmidi - sunnYmage
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
2017-07-18 3:53 GMT+02:00 Thierry Douez <[hidden email]>:

>
>> I want to know if this data contains Chinese characters
>>
>> Thanks for suggestions!
>>
>> Peter Bogdanoff
>>
>>
> ​Hi Peter,
>


​Ok, back after my second morning coffee :)

A better way to check for Chinese code points would be
something like that (not tested and never used myself) :


function testForChinese utf8Text
   return matchText( utf8Text, "\p{Han}")
end testForChinese

Of course, it won't work with  htmlText, but straight with
the text of a field, assuming it's coded in UTF8 !!!


HTH,

Thierry


> ​
> ​Mmm, not sure you'll get *only* Chinese characters,
> but at least any entity with only 5 numbers.
>
> This function returns true if find any, false otherwise:
> ​
> function testForChinese T
> ​xt​
> ​ -- any htmltext​
>    return matchText(
> ​Txt
> , "&#\d{5};")
> end testForChinese
>
> ​Regards,
>
> Thierry​
>


--
------------------------------------------------
Thierry Douez - sunny-tdz.com
sunnYrex - sunnYtext2speech - sunnYperl - sunnYmidi - sunnYmage
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
Thierry, I ended up using your first Regex example—works great!

It is very good to know about \p{} matches—everything from Arabic to Yi. That may come in handy later.

Thanks,

Peter

> On Jul 17, 2017, at 8:54 PM, Thierry Douez via use-livecode <[hidden email]> wrote:
>
> 2017-07-18 3:53 GMT+02:00 Thierry Douez <[hidden email]>:
>
>>
>>> I want to know if this data contains Chinese characters
>>>
>>> Thanks for suggestions!
>>>
>>> Peter Bogdanoff
>>>
>>>
>> ​Hi Peter,
>>
>
>
> ​Ok, back after my second morning coffee :)
>
> A better way to check for Chinese code points would be
> something like that (not tested and never used myself) :
>
>
> function testForChinese utf8Text
>   return matchText( utf8Text, "\p{Han}")
> end testForChinese
>
> Of course, it won't work with  htmlText, but straight with
> the text of a field, assuming it's coded in UTF8 !!!
>
>
> HTH,
>
> Thierry
> ​
>
>> ​
>> ​Mmm, not sure you'll get *only* Chinese characters,
>> but at least any entity with only 5 numbers.
>>
>> This function returns true if find any, false otherwise:
>> ​
>> function testForChinese T
>> ​xt​
>> ​ -- any htmltext​
>>   return matchText(
>> ​Txt
>> , "&#\d{5};")
>> end testForChinese
>>
>> ​Regards,
>>
>> Thierry​
>>
>
>
> --
> ------------------------------------------------
> Thierry Douez - sunny-tdz.com
> sunnYrex - sunnYtext2speech - sunnYperl - sunnYmidi - sunnYmage
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
2017-07-18 6:31 GMT+02:00 Peter Bogdanoff via use-livecode <
[hidden email]>:

> Thierry, I ended up using your first Regex example—works great!
>
> It is very good to know about \p{} matches—everything from Arabic to Yi.

That may come in handy later.
>
> Thanks,
>
> Peter
>
>
​Glad that you like it :)


> >> function testForChinese T
> >> ​xt​
> >> ​ -- any htmltext​
> >>   return matchText(
> >> ​Txt
> >> , "&#\d{5};")
> >> end testForChinese
>

​funny way to re-organize my 3 lines of code ???
Might be a Opera thing ???

should be read as:

function testForChinese Txt
    return matchText( Txt, "&#\d{5};" )
end testForChinese



--
------------------------------------------------
Thierry Douez - sunny-tdz.com
sunnYrex - sunnYtext2speech - sunnYperl - sunnYmidi - sunnYmage
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
of if char 3 to -1 of tItem > 9999

Bob S


> On Jul 17, 2017, at 14:59 , Jonathan Lynch via use-livecode <[hidden email]> wrote:
>
> If the number of chars in tItem = 8 then...


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Find some text characters

J. Landman Gay via use-livecode
Using ";" as the itemdel - makes sense.

I also realized both split and filter could used for this.

None of these beat regex for brevity, though.

Sent from my iPhone

> On Jul 20, 2017, at 11:06 AM, Bob Sneidar via use-livecode <[hidden email]> wrote:
>
> of if char 3 to -1 of tItem > 9999
>
> Bob S
>
>
>> On Jul 17, 2017, at 14:59 , Jonathan Lynch via use-livecode <[hidden email]> wrote:
>>
>> If the number of chars in tItem = 8 then...
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Loading...