INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression Language question  (Read 3455 times)

ChriUwe

  • Recent member
  • *
  • Posts: 9
Expression Language question
« on: February 08, 2017, 12:59:18 am »

Example:

This is My Song [xxxx xxxx]

How can I only show the text for "title" in square brackets in bold  ?
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1855
Re: Expression Language question
« Reply #1 on: February 08, 2017, 02:07:55 am »

One simple solution:

Code: [Select]
=replace(replace([name],/#[#/,/#<b>[#/),/#]#/,/#]</b>#/)
Either use an expression column to replace the [name] column, and use this code as the expression.

Or you could create a user field, eg 'My Name' and use this code as the expression for the field.

Could also be done with regex() function, but would be more complicated, and possibly less efficient. 

The big problem with all such manipulations is the possibility of cases that "break" the code and you end up with either wrong results, or an ever increasing complexity of the expression...
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression Language question
« Reply #2 on: February 08, 2017, 02:51:58 am »

well i think a much simpler and harder to break expression (for your specific example) would be to paste this in an expression column or field

Code: [Select]
=<b>/[[name]/]</b>
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1855
Re: Expression Language question
« Reply #3 on: February 08, 2017, 03:09:25 am »

Wouldn't that result in:

[This is My Song [xxxx xxxx]]

?
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression Language question
« Reply #4 on: February 08, 2017, 03:16:21 am »

 :-X

i don't usually understand most of the (poorly written IMO) examples posted here.  so he has a song that has square brackets somewhere in the title, and he only wants that part in bold?  i thought that was his example song title.

ugh, my bad.  good work mark h
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1855
Re: Expression Language question
« Reply #5 on: February 08, 2017, 05:07:25 am »

Hehe, I know what you mean.  Hopefully, between us, we've covered both options!
Logged

ChriUwe

  • Recent member
  • *
  • Posts: 9
Re: Expression Language question
« Reply #6 on: February 08, 2017, 08:32:26 am »

Thank you for your answers!

So I would like it  ;)

My titles:

- All Along the Watchtower [Live] -------> All Along the Watchtower [Live]
- Changes [Dub] ------->                        Changes [Dub]
.
.
.
and so on  :)

Does somebody has any idea?
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1855
Re: Expression Language question
« Reply #7 on: February 08, 2017, 08:34:30 am »

See my answer above...
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression Language question
« Reply #8 on: February 08, 2017, 04:58:47 pm »

Thanks for posting a much clearer example!

Mark_h posted a working model, a complicated regex might be more robust but it could get funny trying to account for all the possible breaks.  Try his and see if/where it fails on you and we can try to help with that
Logged

ChriUwe

  • Recent member
  • *
  • Posts: 9
Re: Expression Language question
« Reply #9 on: February 09, 2017, 12:19:57 am »

Thank you for your efforts. I have tested the expression of mark_h. It works !!!
 ;)
Logged
Pages: [1]   Go Up